The theory of evolution by natural selection says that changes come about incrementally, as a result of the long-term consequences of small selection advantages for favorable traits. The selection advantage is measured by differential rates in the production of offspring. If organisms with a new and favorable trait produce 101 offspring for every 100 produced by the older forms, the selection advantage s is said to be 0.01. The changes produced by even such a small reproductive advantage can be quite dramatic. If we start with a trait that is present in just 0.1% of the population and if this has a small selection advantage of size s=0.01, this variety will grow to become 99.9% of the population in just under 1,400 generations (in the codominant mode of selection) which is a very short time on the evolutionary scale. (Molecular Evolution, Wen-Hsiung Li, 1997, p. 39)
This presents a bit of a puzzle when it comes to explaining the existence of homosexuality if it is a biological trait, since on the surface it seems to have a selective disadvantage. David Barash has an article that explores what we have learned about the six main hypotheses that have been proposed to get around this problem: kin selection, social prestige, group selection, balanced polymorphisms, sexually antagonistic selection, and nonadaptive byproduct.
He concludes that none of them is the clear winner. But there are many as yet unanswered questions in evolutionary theory that researchers are investigating and this is one of them. He concludes that, like the others, it will be solved eventually.
There are lots of other hypotheses for the evolution of homosexuality, although they are not the “infinite cornucopia” that Leszek Kolakowski postulated could be argued for any given position. At this point, we know enough to know that we have a real mystery: Homosexuality does have biological roots, and the question is how the biological mechanism developed over evolutionary time.
We can be confident that eventually, nature will tell.
In terms of social policy, the answer to this question does not really matter. Treating people equitably irrespective of their sexual orientation means that we do not discriminate based on theories of the origins of the behavior either.