Humanity has a long tradition of trading witty insults as a form of entertainment and one-upmanship, manifested in modern times as rap battles or playing the dozens. These (sometimes) good-natured competitions are found all over the world in many eras of history. One in particular survives in the literature from medieval Britain. Back then, it was called flyting.
Flyting is a stylized battle of insults and wits that was practiced most actively between the fifth and 16th centuries in England and Scotland. Participants employed the timeless tools of provocation and perversion as well as satire, rhetoric, and early bathroom humor to publicly trounce opponents. The term “flyting” comes from Old English and Old Norse words for “quarrel” and “provocation.” 'Tis a form of highly poetic abuse, or highly abusive poetry—a very early precursor to MTV’s Yo Mama and Eminem’s 8 Mile.
“Court flyting” sometimes served as entertainment for royals such as Scottish kings James IV and James V. The most famous surviving exchange is The Flyting of Dunbar and Kennedie, which was performed in the early 16th century by William Dunbar and Walter Kennedy for the court of James IV. A medieval rap battle between two clever men, it featured the first recorded instance of poop being used as an insult. The moment Kennedy called Dunbar a “shit without a wit,” he ushered in a whole new era of scatological humor.
See some examples of flyting from medieval records and read about how it evolved into the rap battles of today, at Atlas Obscura.