There is a theory that explains how homosexuality exists within humanity and all other animals following the "XY Male/XX Female" geneset. You see, for Y to survive inside a female body, the female's body has to have it's immune system shut down for a time. However, the female body doesn't like this very much. So it launches chemical warfare upon the Y chromosome. We know that millions of years ago, Y was attacked vigourously, as we see it in the crumpled, shrunken and scarred state of Y. Damages to Y are causing a lot of problems nowadays. For instance, male fertility has dropped by 50% in 50 years. This isn't the only problem however. Damages to the Y chromosome could cause genetic coding for attraction to be damaged. What does the body then do? Rely on the X chromosome's instructions, which are coded for attraction for males. What about lesbianism, you say? Well, every now and then, because of Y's damaged state, a female can be born with the XY coding. Because they have Y's attraction coding, they are attracted to females. On an interesting note, many families no longer give birth to males, because X has triumphed over Y. My family isn't far behind that; Including all my siblings, me, and all my cousins, there are still three times as many females as males.
However, there are also simpler explanations. Look at the bonobo. They naturally act homosexually as well as heterosexually, and they are 99.98% the same as us. Attraction is genetic in all other animals; or, at least, that's the best guess of anyone. Did gay penguins really contemplate homosexuality before choosing it? Gay penguins are rare, and they certainly didn't see such behaviour in other penguins. Therefore, they didn't outwardly learn it, so it must have been internal.
I'm willing to admit that outside environment can play a role in sexual orientation. But it is a small role, much like in intelligence. With intelligence, genetics are 90% and environment is 10%. I'd say that in sexual orientation, however, the environmental effect is much lower.