The logic behind how a gay gene came into existence to begin with? Or the logic behind why it still exists?
Can't speak to the first one, but as for why it still exists, the gay uncle hypothesis explains it quite well. Consider your extended family - they have some of the same genes you do. If the goal is to ensure that your genes are passed on, but you're gay, your options for doing so are limited. In vitro was obviously not an option until recently. And a gay male impregnating a girl naturally?
Hardly worth the risk of cooties, and I wouldn't trust anything that bleeds for a week and doesn't die. Realistically, it was probably more of a problem of trying to attract a female mate to mother a child with your genes; if you're gay, then there are more attractive sexual/romantic relationships for her to be in....
There still is a way to pass on the genes - if you have siblings and they have kids (your niece/nephew), they have some of the same genes you do, so by sticking around and acting to enhance the probability of survival of those individuals, many of the genes you carry are carried forward, including the possibility of the gay gene being carried forward with no direct reproduction. This sounds really far fetched, but consider the necessity of the gay gene being passed forward in order for any gay population to exist today and the possibility that your niece/nephew carries it and will one day have a gay child.