For centuries, the ancient German city of Worms was a center of Jewish life and learning. The community built its first synagogue in 1034 and by the middle of the seventeenth century, the Jews of Worms had developed a distinctive set of religious practices, many unique within Germany.

Much of what we know about their practices comes from a detailed ritual manual called the “Wormser Minhagbuch” (Book of Customs), composed in 1648 by Juspa Shammes, the community’s official sexton. With a chronicler’s eye for the noteworthy, Juspa recorded the customs he witnessed related to the liturgy, holiday observances, and lifecycle events.

One of the most striking rituals mentioned in the Minhagbuch, known as Shabbat Ha-Bahurim (Boys’ Sabbath), took place on the Sabbath following Purim.

The event began on Friday evening with a procession of boys making their way through the Jewish quarter, banners in hand, behind a leader who “danced wildly, in the dress and manner of a fool.” At the synagogue, the young men took the most prestigious seats and in the morning, the boys received all the honors (except for the rabbi’s blessing on the Torah), which could be traded for gifts of wine. Objections were disregarded. “In short,” Juspa writes, “the Boys’ Sabbath takes precedence, custom uproots the law, and the boys have the upper hand.”

While the Boys’ Sabbath was unique to Worms, many Jewish communities in various places and times held topsy-turvy themed Purim celebrations. Children were made rabbis, kings, or queens for a day, mockery of communal and religious leaders was tolerated and, despite the usual prohibition, cross-dressing was permitted. (Some of those practices — in form, if not content — bear a strong resemblance to folk observances like the medieval Feast of Fools and pre-Lenten carnivals).

Social historians call such role-reversal ceremonies “rituals of inversion.” The function they serve in society, aside from providing an entertaining spectacle, is a subject of debate — a plausible theory holds that displays of inversion and mockery reinforce, rather than undermine, the social order of traditional, hierarchical societies. Institutionalized parody, held one day a year, helps maintain the norms and values of society. The inversion proves the rule.

If rituals like the Boys’ Sabbath fulfill a particular social function, we still have to explain why they are associated with Purim. The answer, of course, is that inversion is the key to Megillat Esther. If any Jewish holiday deserves its own inversion ritual, it is Purim.

The Megillah’s symmetrical structure is unique within the Bible. The first chapters build toward a turning point, when a thin-skinned, volatile, and easily manipulated king orders Haman to hold a parade in Mordechai’s honor instead of signing off on his execution, as Haman expected.

From there, things move rapidly in reverse.

On the opposite side of the Megillah’s climax, verses repeat themselves nearly verbatim, but in mirror image: “Haman went out happy and lighthearted” is inverted into “Haman hurried home, his head covered in mourning.” First, “the city of Shushan was dumbfounded”; later, “the city of Shushan rang with joyous cries.” “Great mourning among the Jews, with fasting, weeping, and wailing” is transformed into “gladness and joy among the Jews, a feast, and a holiday.” The reader can almost fold the text along an axis of symmetry that divides the winding action from its unwinding. Near the Megillah’s conclusion, the phrases ve-nahafokh hu (the opposite happened) and ha-hodesh asher nehepakh (the month which was transformed) draw the reader’s attention to the leitmotif.

La-hafokh means to reverse or transform, but it also means to destroy — to subvert, rather than invert. God “upended” (hafakh) Sodom and Gomorrah. “In forty days, Nineveh shall be upended (nehepakhet),” in the words of Jonah’s unfulfilled prophecy. The same root can also denote social or political upheaval — in modern Hebrew, mahapekha is a revolution.

The sight of order turned to chaos, truth replaced by lies, and children impersonating leaders is funny, and perhaps socially stabilizing, so long as it is also temporary and reversible. We can laugh at the parodies of a Purim shpiel because we know that reality takes over at the play’s conclusion.

Permanent social inversion, on the other hand, is a story of madness, not irony. It is the plotline of false messiahs who shout slogans like “cultural revolution” and “let’s take our country back” and “the deconstruction of the administrative state.” But the grand bargain they strike with their followers, to redeem society by means of its destruction, is a fraud. Visionaries who see an apocalypse as the first step along the path to a glorious future succeed only in delivering the first step, with all of its misery — their utopia never materializes. That narrative is no cause for celebration.

May the inversions of Purim always bring much delight and, at the same time, provide a renewed appreciation for a world turned right-side up. And may they always last no more than a day.