It's got nothing to do with carrying genes forward. It's socialization, companionship, pleasure. While those things are not necessary on a species level, they are necessary on an individual level. Physical affection bonds individuals together.
Now, if you read the wiki links I provided, there are some lower critters that do things that appear gay for purely biological reasons, as well. Or, in the case of hyenas, sexual orientation is a function of hormones. Female hyenas that were exposed to higher levels of testosterone in utero are more dominant and will apparently "mate" with other female hyenas.