In doing some research, I came across this interesting book by psychologist Dr. Louis Berman. In The Puzzle: Exploring the Evolutionary Puzzle of Male Homosexuality, Berman discusses the probable genetic causes of homosexuality, and proposes that before six weeks of gestation, all humans have a "proto-female" brain, which, in the case of boys, then gets "washed" with hormones that "masculinize" the brain. Some boys get more of this than others, and those with "Low Masculinized Brains" often turn out to be homosexual. He also discusses how he believes there is no evolutionary advantage to homosexuality.
You can also read