The short answer is that we don't know, but several good theories are presented. My two favorites are the "sexually antagonistic selection" theory and the "nonadaptive byproduct" theory.
Here's the sexually antagonistic selection theory:
What if one or more genes that predispose toward homosexuality (and with it, reduced reproductive output) in one sex actually work in the opposite manner in the other sex? I prefer the phrase "sexuallycomplementary selection": A fitness detriment when genes exist in one sex—say, gay males—could be more than compensated for by a fitness enhancement when they exist in another sex.
Anyone prefer any of the other theories? I'm skeptical of the group selection and social prestige theories. It seems like there would have to be a pretty enormous benefit conferred upon one's relatives to offset not having children of one's own.