According to Roughgarden, gayness is a necessary side effect of getting along. Homosexuality evolved in tandem with vertebrate societies, in which a motley group of individuals has to either live together or die alone. In fact, Roughgarden even argues that homosexuality is a defining feature of advanced animal communities, which require communal bonds in order to function. “The more complex and sophisticated a social system is,” she writes, “the more likely it is to have homosexuality intermixed with heterosexuality.”
Japanese macaques, an old world primate, illustrate this principle perfectly. Macaque society revolves around females, who form intricate dominance hierarchies within a given group. Males are transient. To help maintain the necessary social networks, female macaques engage in rampant lesbianism. These friendly copulations, which can last up to four days, form the bedrock of macaque society, preventing unnecessary violence and aggression. Females that sleep together will even defend each other from the unwanted advances of male macaques. In fact, behavioral scientist Paul Vasey has found that females will choose to mate with another female, as opposed to a horny male, 92.5% of the time. While this lesbianism probably decreases reproductive success for macaques in the short term, in the long run it is clearly beneficial for the species, since it fosters social stability. “Same-sex sexuality is just another way of maintaining physical intimacy,” Roughgarden says. “It’s like grooming, except we have lots of pleasure neurons in our genitals. When animals exhibit homosexual behavior, they are just using their genitals for a socially significant purpose.”
Link from a recommendation at Marginal Revolution of Roughgarden's recent
The Genial Gene.