Consider the Season Two episode “The Gang Runs for Office.” Yes, the plot — which sees Dennis (Glenn Howerton) run for local office so he and his friends Charlie (Charlie Day), Mac (Rob McElhenney), Dee (Kaitlin Olson), and Frank (Danny DeVito) can earn income by soliciting bribes — is farcical. But it gets at the deeper reality of how some people see government: corrupt, inefficient, a game rigged against them. Similarly, Frank’s comments about Hillary Clinton, whom he calls “awful” because she “hates freedom,” should have served as a stark warning for Democrats in 2016. Frank may not be the most sympathetic character in the world — indeed, that whole exchange is intended to make him look like a misogynistic jerk — but he’s right about how Clinton appeared to many average voters. Regardless of whether or not Clinton actually “hates freedom” (Which freedoms? Hates how?), the perception that she did was baked into the cake as far back as 2006.

Now, in the sitcom’s 13th season, writers have kicked it up a notch and given episodes a running theme: gender politics. But they have done so in a manner that is rarely didactic and often immensely funny, weaving insights about the ridiculous world in which we live into “It’s Always Sunny’s” ridiculous characters.

Look at the season premiere, during which it seemed as if resident psychopath Dennis might be replaced by Cindy (Mindy Kaling). Cindy dreams up a genius effort to drive sales by ginning up outrage against a neighboring bar and selling a wine labeled “Liberal Tears.” There’s another meta-story at work, however, about a woman of color replacing an emotionally abusive white guy in the workplace and the fact that the group, including its women, chooses to side with the emotionally abusive white guy by episode’s end.

The season’s second episode, during which the friends participate in an “escape room,” was funny for all the reasons “It’s Always Sunny” tends to be funny: It was about five people who not-so-secretly hate each other forming factions in order to screw the others over. But if you were paying attention to certain clues (talk about the roles of men and women; discussions of posture and animals and eye contact), you might think the show was subtly mocking Jordan Peterson and his adherents for suggesting that life consists of a series of simple tricks one must master to live well. I tend to think of Peterson’s advice as banal rather than existentially threatening. (Standing up straight and keeping your room clean aren’t revolutionary concepts.) But its very banality makes it ripe for humor. And, assuming the jibes were intentional, “Always Sunny” writer Megan Ganz played it well by keeping the criticism sotto voce instead of turning the episode into a diatribe.

The most recent episode of “It’s Always Sunny,” which mocked the epidemic of gender-swapped reboots, was less successful than its predecessors because it felt like a diatribe. “The Gang Beats Boggs: Ladies Reboot” is, as it sounds, a (nearly) ladies-only reboot of Season 10 premiere “The Gang Beats Boggs.” But with more gross-out humor! The bit didn’t quite work for me, if only because the characters kept talking about the general silliness of rebooting properties with women in the lead roles. Or perhaps this was another meta-joke, aimed at the people constantly complaining about the uselessness of such productions.