But it's pretty unlikely.
If there were a gene variant that caused homosexuality when the population grew large, then as the population grew, the people with this gene variant would just be outbred by the people without this gene variant. It'd be pretty strong selection pressure against it.
The typical response to this is to invoke group selection as a possible mechanism. Whether group selection has any large effects at all is pretty controversial, and it would have to have a pretty big effect to account for this.
Dubious as it is, this hypothesis has one good thing going for it. It makes predictions that can possibly be tested. Homosexuality should occur more often in crowded conditions. With humans there are obviously other confounding factors (how many people in more liberal, urban areas with denser populations feel comfortable coming out?). Maybe someone could get some data on sheep (I can't think of another species off the top of my head with a high rate of exclusive homosexuality, as opposed to bisexuality)? It would be quite expensive to set up an experiment just for this, but if there's be some way to survey sheep populations living in different conditions, it would at least provide a test for this hypothesis.
I think a much better hypothesis is that whatever genetic variants make a certain percentage of us end up gay confer some advantage to people with another mix on them. I.e. a heterozygote advantage. The canonical example of this is the ?-hemoglobin allele that causes sickle-cell anemia in homozygous carriers, but confers resistance to malaria in both heterozygous and homozygous carriers. Deadly as it is to people with two copies, it confers a substantial benefit to those with one (in areas that have lots of malaria at any rate). Outside these areas, it's almost purely disadvantageous.
As it happens, there is a bit of evidence that the female relatives of gay males are likely to have more offspring in general:
http://www.springerlink.com/content/q4579x2370758366/I don't know if anyone has tried to reproduce it.
Another hypothesis is that it's caused by some sort of pathogen (e.g. a virus) that acts on a critical region of the brain at a critical time. In this case, you wouldn't necessarily need to explain how evolution sustains it...except that we know empirically that there's a substantial genetic component (from the Bailey & Pillard twin studies, for example), so unless such a pathogen were relatively new, we'd still have to explain why there wasn't selection against people that had genes that make them susceptible to the pathogen.
Yeah, I know I've rambled on forever.