There are numerous evolutionary mechanisms that might explain homosexual behaviour, which is common in many species of animals
"Simple reasoning shows that evolution cannot explain homosexuality - how would a homosexuality gene get selected for?" "Why have the genetic traits predisposing to homosexuality not been eliminated long ago?"
Such arguments are surprisingly common - and completely wrong
Homosexual behaviour has been observed in hundreds of species, from bison to penguins.
.
.
.
Reasons why
Among animals, homosexual behaviour is usually non-exclusive. For instance, in some populations of Japanese macaques, females prefer female sexual partners to male ones but still mate with males - they are bisexual, in other words
It has also been suggested that homosexuality boosts individuals' reproductive success, albeit indirectly. For instance, same-sex partners might have a better chance of rising to the top of social hierarchies and getting access to the opposite sex. In some gull species, homosexual partnerships might be a response to a shortage of males - rather than have no offspring at all, some female pairs raise offspring together after mating with a male from a normal male-female pair
Another possibility is that homosexuality evolves and persists because it benefits groups or relatives, rather than individuals. In bonobos, homosexual behaviour might have benefits at a group level by promoting social cohesion. One study in Samoa found gay men devote more time to their nieces and nephews, suggesting it might be an example of kin selection (promoting your own genes in the bodies of others