Hamelin in Lower Saxony, Germany, was overrun with rats, per the Pied Piper legend. Then along came a stranger, clad in pied (multicolored) clothing, who asserted that he could rid the town of its pests. The authorities promised him a reward – 1000 guilders in some versions – if he succeeded. So the man, known thereafter as the Pied Piper of Hamelin, pulled out a pipe, and began to play it. The rats, entranced by his music, flocked to and then followed him out of town and into a river, where they all drowned. However, when he sought the promised payment, the good people of Hamelin stiffed the piper. They either refused to pay, or paid only a fraction of the promised amount – 50 guilders, in some accounts. The understandably upset piper left the town in a huff, vowing revenge. As seen below, the tale had possibly dark real life origins.
A Legend With an Exact Date

Few myths have exact dates for when they’re supposed to have happen, and are more in the “once upon a time” category. The Pied Piper legend is different: its key event has a precise date: June 26th, 1284, the date when the Pied Piper supposedly returned to Hamelin.
Per the legend, while all of the town’s adults were gathered in church, the Pied Piper played his pipe, and entranced Hamelin’s kids – 130 of them – to follow him out of town. They were never seen again. Only three children were left in town when the adults exited the church: a crippled child who could not follow the piper, a deaf one who had not heard his tune, and a blind kid who was unable to follow the other children.
The Real Life Event Behind the Legend

The earliest known mention of whatever took place is found in a 1384 entry in Hamelin’s town records, which bleakly states: “It has been 100 years since our children left”. The earliest record was a stained glass window made for the town’s church around 1300 – about sixteen years after the children were supposedly taken. The window was destroyed in the seventeenth century, but written descriptions of it survive, the oldest of which dates to around 1440.
As to what was actually behind the legend, a leading theory is that the children starved in a famine. Other theories argue that they might have died in an epidemic, or otherwise perished in some disaster, and the Pied Piper symbolizes Death. Other theories have it that the Pied Piper was a recruiter for emigration to the east – popular at the time after victories opened up the Baltic region and Eastern Europe to German colonization.
The Disappearance of Hamelin’s Young

Recruiters known as lokators went to town and villages in search of settlers. They were glib talking, and often dressed garishly and played musical instruments. A lokator might have drained Hamelin of most of its youth. Another possibility is that in the midst of famine, Hamelin’s parents expelled their children. Life was orders of magnitude tougher back then, and desperate people were sometimes forced into desperate choices. Another theory is mass hysteria.
The era witnessed numerous dance mania outbreaks. One such, in 1237, saw a large group of hysterical children, dancing and jumping, travel from one town to another. A darker possibility is that the Piper was a vicious pedophile, who crept into Hamelin to snatch sleeping children. We may never know the exact details. However, it is clear that something bad that involved Hamelin’s children happened in 1284. It left the town traumatized for centuries afterwards, and inspired the Pied Piper of Hamelin legend.

_________________
Some Sources & Further Reading
Ancient Origins – The Disturbing True Story of the Pied Piper of Hamelin
Fortean Times, No. 264 – The Lost Children of Hamelin
History Halls – Hoaxes: Piltdown Man, One of the Most Devastating Pranks in Science History
