One of the perennial questions It's Always Sunny in Philadelphia (2005-) has faced has been: how do we define Mac as a character? A lot of the show's attempts to create a strong character have resulted in aborted arcs, and the character's personality and defining traits have shifted wildly throughout the show. While Mac began the series as an insensitive ladies man, the show also framed him as a fatherless son desperate for family, a mixed-up Catholic, and - infamously - "Fat Mac." In later seasons, a fundamental but seemingly unexplored aspect of Mac's identity becomes a defining aspect of the character: the formerly womanizing Mac is actually gay.
Centered around the gang's intense homosocial bonding or "bromance" (particularly between the four male members), the sitcom has had a long history of playing those traits up and blurring the line of homoeroticism. In "The Gang Sells Out," Mac and Dennis appear well-versed in the ins-and-outs of gay sex. Their in-depth knowledge of homosexual bedroom practices could be a fun idea cooked up in the writer's room to suggest that Dennis and Mac have had a homosexual relationship. Or, it could be a commentary on how the gang is so dysfunctional in human relationships that they don't know how to properly have a homosocial relationship, instead often blurring the lines between homoerotic and explicit homosexual overtones. The episode "Mac and Dennis Break Up" demonstrates their dysfunction, suggesting that they are unable to understand healthy homosocial bonding. In the Season 5 premiere, "The Gang Exploits the Mortgage Crisis," Mac and Dennis literally put on a show as a homosexual couple (a meta commentary of sorts) for real estate buyers. Their argument over who is the dominant sexual partner can be read as a way for two co-dependent friends to navigate the power struggles of friendship through an ostensibly ridiculous hypothetical scenario (that they both seem to be taking too seriously, which is the source of the comedy). But it can also be interpreted as a way for the two friends to express their suppressed sexual feelings for one another in what they perceive to be a socially acceptable way.
In later seasons, however, the dynamic has clearly changed, and it becomes clear that Mac is a closeted homosexual romantically infatuated with Dennis. Three seasons after "The Gang Exploits the Mortgage Crisis," the eighth season episode "The Gang Dines Out" features another argument between Mac and Dennis about the nature of their relationship as they are dining at a table for two. There is no coded language and they are not talking about an imaginary relationship. While the show mines humor from the fact that the waitstaff mistakenly believes that both pairs of diners in the episode -- Charlie and Frank as well as Dennis and Mac -- are gay couples, there's a very strong implication in language and tone that Mac and Dennis really are a gay couple. In later episodes such as "The Gang Misses the Boat" and "Mac Day," the other members of the gang overtly define Mac as gay.
The increasing emphasis on this aspect of Mac's character raises the question: did the writers always intend to depict Mac as gay? Was his womanizing in early episodes, like "Charlie Wants an Abortion" and "Paddy's Next Billboard Top Model," overcompensation meant to hide his true feelings?
It's important to note that the five main characters on It's Always Sunny in Philadelphia have various levels of dysfunction and those layers have been gradually peeled back bit by bit. For instance, Charlie is initially presented as dyslexic, hypermanic, and having a strong attachment to the waitress. It's eventually revealed, however, that he had little in the way of parental guidance and he was molested by his uncle. Dennis is a narcissist who's obsessed with his body image, but we later learn that he was nearly invisible in high school and is likely compensating for that experience. These developments seem entirely natural in the context of what we know about the characters. In light of the style of the show, some viewers feel that Mac's homosexual tendencies were apparent throughout the run of the show but that he is only able to come to terms with it in later seasons. This reading changes the show quite a bit: the homosocial tension between Mac and the rest of the gang is rewritten as unrequieted attraction. One could even assume that Mac's sexual love for Dennis' mother was a manifestation of his desire to possess Dennis himself.
Another option is that Mac's overt homosexuality is a retcon of sorts. It is possible that Mac's overt homosexuality in later seasons is the result of flanderization, which is defined by TV Tropes as "The act of taking a single (often minor) action or trait of a character within a work and exaggerating it more and more over time until it completely consumes the character." Flanderization - named after a character on The Simpsons (1989 - ) - would make sense in the context of a show trying to find an angle on a somewhat elusive character.
It was after Mac lost his fat that his overt gayness became an angle the show decided to pursue. Like "Fat Mac," it is possible that "Gay Mac" is a continuity-buckling direction the writers want to take Mac. Even more interestingly, perhaps the writers decided to have fun with fan speculation that Mac was gay and actually write it into the plot.
Early episodes of the series offer neither definitive proof that Mac was written as gay all along nor proof that he wasn't. With this ambiguity, it is up for the viewers to decide whether the writers decided to take a left turn or were laying the seeds for this development all along.