OK, first we need to define our terms. Homosexuality isn't an evolutionary puzzle, any more than masturbation is. What's an evolutionary puzzle is an exclusively homosexual orientation.
Now, having conceded that that's an evolutionary puzzle, let's immediately point out that it's no more of one, in principal, than any number of congenital conditions that threaten successful reproduction, such as Tay-Sachs or sickle cell. (That's not to say that having a homosexual orientation makes you sick; just that from the genes' point of view it's as if it does. But the genes' point of view neither is nor ought to be the same as ours.)
There are several ways in which things like this can happen. One is that although the condition in homozygotes is "gene-fatal", being a heterozygous carrier of the condition confers some evolutionary advantage that outweighs that. This is unlikely but not impossible in the case of homosexuality.
Another is that though congenital, the condition is not innate in origin, but developmental. There's some evidence that at least some of the time the uterine environment may play a role in male homosexuality, such as the intriguing finding that you're more likely to be gay if you have an older brother, whether or not you grew up together, but no more likely to be gay if you have an older stepbrother or paternal halfbrother. However, this is almost certainly not the whole story or anything like it.
The most likely explanation is that a homosexual orientation arises partly through the developmental environment and partly through innate factors that are polygenic: that is, that arise from a combination of effects caused by many genes in many loci. Such traits don't breed true, because they arise from the unique genetic hand you're dealt rather than from any one of the cards in it, and sexual reproduction involves shuffling the pack. So a polygenic trait presents natural selection with a moving target. Such traits can't be selected for, and they can't be selected against.