I'm currently reading _English Sexualities, 1700-1800_ and finished the chapter on the molly subculture that arose in London. There is (or at least was -- dunno the current state of it) some debate about whether this was a fully fledged gay culture, or if it is a proto gay culture. Apparently Michel Foucault was so attached to his theory about medicine and its normalizing/prescriptive effects on society that he didn't think a fully fledged gay culture could exist until homosexuality was medicalized and it hadn't been yet therefore, etc. What a stinkily ridiculous theory that is. Medicine is an enforcement mechanism. The ideas tend to come from elsewhere. Whatever.
In any event, none of the explanations proposed for the rise of molly subculture (some of which further attempt to explain why it manifested the way it did) makes much sense to me. Hitchcock muses that, hey, Masons started up around the same time with a lot of the same characteristics. Maybe you don't _need_ a special explanation. Which brings me back to _The Wisdom of Crowds_.
If people are scattered about the countryside, engaging in non-penetrative (so non-reproductive) sexual activities, either as heterosexual couples, small groups or other, it's probably fairly easy to perceive human sexual behavior as being a continuum (with some of those behaviors Sin, but nevertheless potentially very fun and desirable). If there are a bunch of guys jacking off as a group post-swim, for example, the guy who really likes other guys (more or exclusively) in the crowd isn't likely to stand out.
Fast forward a decade or a century and move these people to a city. There are a lot more people to hang out with and at least some chance to find other people more like yourself. Apply a small amount of persecution so they huddle together (but not so much that they don't perceive it safe to meet) and you should precipitate private clubs and special communication. More importantly, you'll probably precipitate categories out of what might otherwise have remained a continuum. And therein lies the birth of identity.
Maybe. It's a theory.