Sort of a random expression of a gene that occurs at some % level in the population, as opposed to "you're gay because your parent is gay" type of thing that implies direct inheritance.
Something that's always fascinated me is that the entire bonobo population is "sexually" active, and all are basically bisexual. They're also what one could call pedophiles (they even sexualize infants, ewww, but rationally I don't think it's proper to impose human objections onto their behavior). An interesting outcome of their sexual profligacy is that their society is relatively peaceful, and the females are mostly "in charge" of their groups, certainly much more so than their chimp cousins. It's theorized that the females collectively being wanton hussies (I say that affectionately) means that males don't know which of the offspring are their own, therefore, they don't fight over exclusive breeding rights, and instead the males are affectionate towards, and look after ALL the young, because any of them could be their own kids or grandkids.
This could also play a part in why right-wing macho men are so obsessed with controlling female's sexuality, and punishing same-sex behavior. Deep in their psyche there's an awareness that it leads to erosion of their collective societal power. Compare the societies of chimps (much more of a "tournament" species where all the females of the group constitute a "harem", and are the "property" of the alphas) to bonobos and you'll see some strong parallels (except the pedo part) to conservatives and liberals in humans. Bonobos are also MUCH more welcoming to outsiders than chimps, and this is just scraping the surface.
I speculate that homosexuality (specifically) in human males evolved as a way to keep the peace in tournament species (like chimpanzees, though it's origins can be found much "further back" than chimps) wherein if a certain % of the males are instead attracted to one another rather than the females (that the alphas believe they "own" and have exclusive breeding rights with), this will notably reduce the number of fights over sexual primacy that result in severe injury and even death among the population. If you're going to be a "tournament" species, the species needs for a certain % of the males to actually not even be interested in breeding with the females, IOW.