The Scarlet Pimpernel by Baroness Orczy is set during the French Revolution. During this time, of course, the people were bloodthirsty for the heads of aristocrats and were desperate to punish anyone who was perceived as being (and sometimes actually were) responsible for their poverty and despair.
As the story opens, we are introduced to the world of deception, violence, and intrigue in the middle of a revolution. At the gates in and out of Paris, carts and carriages are routinely searched for aristocrats who are trying to escape certain beheading. More and more of the aristocrats who are in prison are managing to escape, primarily through the efforts of a mysterious man who calls himself the Scarlet Pimpernel.
One particular guard, Sergeant Bibot, is exceptionally skilled at ferreting out these hidden aristos, and everyone has begun to gather at his gate to watch the spectacle of their hated enemies, the aristocrats, being discovered and sent back to prison. Bibot routinely makes a dramatic spectacle of these moments.
One day Bibot tells everyone the story of a fellow guard who foolishly let some aristocrats get through. Even worse, the driver of the cart was the notorious Scarlet Pimpernel, which made the hapless guard a target for everyone's mockery. Bibot is merciless in his mockery of the poor guard. In fact, partway through the story,
Bibot was laughing so much at his own tale that it was some time before he could continue.
Soon, an old hag drives a cart to this gate. Bibot is disgusted by the woman, as she collects the hair of the beheaded aristocrats. When she announces that she is going to take care of a sick child--perhaps suffering from smallpox--Bibot has no interest in detaining her (for fear of being contaminated by the dread disease) and lets her pass through the gate.
Minutes after the woman is gone, an officer rides up to the gate and asks if an old woman has tried to pass through the the gate--an old woman who will probably claim that she is taking care of someone with smallpox. Bibot is horrified when he learns that there were aristocrats hiding in the cart; even worse, he is mortified to learn that the old woman was the Scarlet Pimpernel in disguise.
Dramatic irony occurs when there is a contrast between what is expected and what happens, a scenario which generally promotes ironic humor. The irony of this situation, of course, is that the very thing Bibot so arrogantly and mockingly taunted the other guard for doing is the same thing that just happened to him. It is a perfect irony.