The concept of punishment in the afterlife is as old as the afterlife. Many cultures from around the globe have had some notion of divine justice in death. As early as 1275BCE we have images Anubis testing a Pharaoh's heart; should the heart be deemed weighted down by more evil than good, it was to be fed to the nearby beast Ammut. Buddhism was founded in the 6th century BCE and it features several hells (or Narakas) and heavens. As religions persist, their standards of hell evolve with the times. By the Tang Dynsaty, Buddhist and Taoist traditions mixed together in China, to create 18 layers of hell, punishing people proportional to their sin, (either for a fixed time or depending on interpretation). What's important to note is, the idea of karmic retribution is common across most religions despite these traditions developing independent from one another. Not to speak heads or tails on one's religious beliefs, but the pervasiveness of divine justice is a popular, and at its most basic, the notion that those who create suffering in life would suffer in death is the root of ironic punishment.
For most in the Western world, the earliest hell comes from the Tartarus of Greek Mythology. While the realm of Hades was pretty innocuous in its own right, the Tartarus was a deep abyss where specified punishment was dolled out. Originally the Tartarus was a prison for those who opposed the gods (an idea that would be recycled with the Christian hell in Paradise Lost), but was later used as a place to punish the more wicked humans. By the time of Rome, Virgil describes the Tartarus as a land with a "flaming river"
The most common interpretation of Christian Hell comes from The Inferno by Dante Alighieri in the 14th century. In this poem (the first part of an epic detailing a journey through hell, purgatory and heaven) Dante travels through 9 levels of hell, each one dealing with specific sins and punishing them accordingly. In the Christian tradition Hell is only described as "A lake of Fire" but Dante expands on this with icons from Greek and Roman myth. Throughout the Inferno Dante evokes myths and monsters, from the Minotaur to Medusa and juxtaposes it with daemons from Catholic lore. The journey is very evocative of well known myths and lore, specifically Odysseus's journey through Hades in the Odyssey. The work was incredibly popular in its day, providing a tangible face (albeit non canonical) to the threats of fire and brimstone preached in sermons.
One of the reasons the Inferno persisted in the Christian zeitgeist is because of how Dante doesn't weigh all sins as equal. While in the Abrahamic tradition, all sins are cause for condemnation, Dante shows sympathy for the more human sins. The virtuous pagans live in limbo (an area akin to the realm of Hades from Greek myth). the lustful, the glutinous and the greedy are given sins on the first few levels of hell. There's is a life of suffering, but the irony come from consequence to their foibles. In the 5th circle, the wrathful and misanthropic fight eternally among themselves in the waters of the river Styx; here they create their own hell by being wrathful. Only when we enter the deeper circles (and what we would commonly read as more over sins) do we see direct punishment. Blasphemers eat shit, heretics burn in oven tombs and pimps are whipped by demons, forced to run back and forward for eternity. To the faithful all of this is very satisfying. It is worth noting, though, that while this image of hell persists in Christian culture, in the religious texts, this type of layered retribution is nowhere to be found and the actual conceptualization of hell left comparatively ambiguous to most other religions.
In Islam, there are seven gates of hell, specific to each sinner, with hypocrites receiving less severe punishment than those who maliciously fought against God. While Christian hell is vague, and often thought of in spiritual terms as something separate from God, the hell in Islam is run by God himself. The Quran gives vivid details of skin being burnt off and reapplied only to be burnt off again (something not too dissimilar from the hot Narakas of Buddhism). Outside of the Quran several hadiths (in Islam a hadith is a semicanonical tradition that isn't in the Quran... at all, but is accepted by and large by the community. There are tons of hadiths that often conflict with each other and the reliability/acceptance of a hadith is largely contingent on the perceived trustworthiness of the source, eg: the infamous 72 virgins hadith is from a very unreliable source and is largely disregarded by most practicing Muslims) describe hell in different ways, but many specifying the punishment in hell to a specific sin, eg: one tradition states that whomever doesn't pay Zakat, or a tithe, will have a snake biting at his face saying "I am your treasure."
Today we kind of treat the ironic punishment as a punchline in media - the robot devil from Futurama is obsessed with ironic punishment to the point of absurdity, but this idea is not limited to Christianity, nor any religion. For most human history and even into the time of writing this, the notion of an ironic afterlife isn't ironic at all, it's simply been understood to be an inalienable aspect of justice.