"This is a paradox from an evolutionary perspective," says Paul Vasey from the University of Lethbridge in Canada. "How can a trait like male homosexuality, which has a genetic component, persist over evolutionary time if the individuals that carry the genes associated with that trait are not reproducing?"
https://www.bbc.com/news/magazine-26089486
Evolution doesn't only favour heterosexuality, it also favours monogamy. Monogamy isn't solely a religious or cultural construct because back in the Stone Age a fatherless family would've had far more difficulty in defending and feeding themselves. A promiscuous father would've had less ability to raise children with multiple partners in prehistory where resources were far more limited and the child maintenance payments were less enforceable due to an absence of a court system. So the more special, unique, rebellious and intense the desire for a specific person, the more likely it'd continue as a monogamous relationship. Thus any trait correlated with monogamy at the expense of promiscuity is evolutionarily viable. Not all homosexuals are monogamous in the same way that heterosexuals can switch partners, but evolution works over 1000's of years and so only a slight long-term correlation is sufficient for a trait to pass on.