There are things that make this fairytale seem more real than others such as, the name of the town inserted into the story, the year this supposedly happened, and the very specific number of 130 children leaving. Thank you!
First, a tedious discussion of terms (because it really is necessary): the legend of the Pied Piper is a legend, not a fairytale (or a folktale). Legends are told to be believed and they often end tragically. Folktales are fictional: they are not told to be believed and they usually end happily - 'happily ever after'. 'Fairytale' is a problematic term that is either the exact counterpart of folktale or it is better applied to abridged, published versions of folk narrative - but usually of folktales.
So it is important to point out that here we are dealing with a legend, and as such, narrators usually attempt to do whatever it takes to make the story believable. This includes describing exact places, times, and specifics so that the account seems very real (even though it may not be). There are many similar legends that recall the Legend of the Pied Piper, and this is usually the first clue that we are dealing with a fictional account even thought it was told to be believed.
That has not stopped numerous people from trying to uncover the 'true story' behind the piper who lured away rats, and then children, from the German village of Hamelin. It is part of folk belief that there is some truth behind every legend. This is not necessarily true, but the belief that it is true persists - and is the source of many questions on /r/AskHistorians!
I doubt that any satisfactory 'true story' is likely to emerge about what is 'behind this legend'. That said, there can be numerous things that can put wind into the sail of a legend: it is a compelling story (and people are suckers for a good story); some event(s) recalled the sudden disappearance of part of a population (i.e. the plague, immigration, or some other factor); and there are deeply rooted folk traditions about the seductive if not magical qualities of really good musicians some of whom lure people away to their demise. These factors can work together to give strength to this legend, but none of them stand alone as its single 'source'.