I doubt there's a single gene that would determine someone's sexuality. I feel that levels of hormones (completely outside our control) could maybe be a factor in sexuality and sexual identity, because chemistry seems to have a pretty profound effect on us. I don't know if that relies on a single gene, but I'm going to guess that things like how much estrogen or testosterone or anything else that we produce is probably going to rest on a multitude of genes. Plus, different chemicals probably interfere with our lives in ways we have no idea of yet. It's a pretty interesting discussion for me because I like biology (never said I'm good at it), but I'm in the camp that it doesn't really matter why people aren't straight; they deserve human rights just as much as any straight person.
As for evolution, it hasn't been selected against to such a degree that gay people don't exist, so perhaps it serves some purpose, or perhaps it's just there in the gene pool and doesn't cause enough harm that natural selection would have struck it out.