There are several possibilities.
1. If having gay relatives improved the chances that you will have children and they would survive to themselves reproduce, then evolution could favor maintaining a gay gene.
Remember that for nearly all of our species' existence, and that of the pre-humans we evolved from, we've lived most of our lives in arrangements where our close relatives lived near us and most people in the region were also related to us.
Your children have half your genes. Your siblings' children have a quarter of your genes. So in effect two of your siblings children are equivalent to one of your own as far as getting your genetic material into the next generation goes.
If being gay meant that your sibling does not have their own kids to take care of and so they devote effort that would have gone to raising their own kids to helping their straight siblings' with their kids or to doing things that help the village that those with kids don't have the time for, that might greatly increase the survival rate of those kids enough to make up for not having kids of their own.
2. Being gay doesn't mean you can't have kids. Throughout most of our history, many many people have had kids with people they have not been attracted to. That goes for both gay people and straight people.
3. What if it were a bisexual gene rather than a gay gene? Having people in your tribe that can form with both men and women the kind of close bonds the people form for the sexual partners has some obvious advantages.