It's complicated. The most compelling theory is that several genes might have a bit of an influence paired with the hormonal conditions in the womb. Here's an overview:
https://en.wikipedia.org/wiki/Epigenetic_theories_of_homosex...