Rip Van Winkle stories are present in many different mythic traditions. That is, in many traditions there are stories about someone going to sleep for an unnaturally long period of time, then waking up not realizing how much time has passed. One of the oldest and more prevalent of these myths is that of a Cretan poet and prophet who was said to have slept in a cave for between forty and sixty years (depending on the source).
Similar stories have been communicated in Medieval Europe, Near Eastern mythologies, and the Koran. They do not generally start with such a strange preceding event as in "Rip Van Winkel," but many such tales do incorporate such an event, as in a Chinese myth, where a man comes upon some aged men playing chess in a mountain grotto, and when he puts in his mouth a certain stone they give him, he sleeps for centuries.
Although Washington Irving had likely come across one or another of these tales at some point, his primary source is most likely an old German folktale about Peter Klaus, published in 1800. In this story, Klaus, a goatherd, follows one of his goats into a crack in a cliff, where he meets a man who beckons him to follow. They end up in a hollow surrounded by high walls, where twelve knights, none speaking a word and all looking very serious, are bowling. Klaus is made to set the pins for them.
He eventually has the confidence to drink from their vessel, which greatly rejuvenates him, and he continues to do so any time he gets too tired, until eventually he falls asleep anyway. When he returns to his village on what he believes is the next morning, he finds everything changed, and only upon finding his daughter, who says that her father disappeared twenty years ago, does he understand that twenty years have passed. The parallels between the Peter Klaus story and “Rip Van Winkle” are quite clear, and Irving was even accused of plagiarism. Although adapting foreign works in this way was fairly common at the time, Irving did add a note to his text.
Interestingly, there is also a non-mythical Rip Van Winkle phenomenon, which could be an origin of these tales. So-called Rip Van Winkle disease, officially Kleine-Levin syndrome, an incredibly rare disease, usually begins around puberty, often following a flu-like infection. In this disease, a teen will fall into a sleep that lasts weeks or even months, and this will happen again reguarly, but less and less frequently as the person ages, until in the person's late twenties or so the symptoms tend to disappear. The hypersomnia bouts usually last about ten days, but one young woman once slept nearly a year, rising only to shovel food into her mouth, bathe, and take care of bodily functions, all in a hazy, confused state. A person with this disease, while in a period of hypersomnia, exhibits the normal sleep phases, as opposed to someone in a coma, but it cycles endlessly for days, weeks, or months, with no waking phase. Although no treatments can safely help during these periods, virtually all who suffer from the disease outgrow it.
Even without a medical analogue, however, there is something intriguing about the idea of a person appearing from the past and not knowing about everything that has happened. "Rip Van Winkle" is a species of time-travel narrative in which the traveler ages normally and the time-travel technology is a special drink. Part of the interest in such tales is the observation that a person can feel out of place even in his own town, with society changing drastically even in one generation. Consider Homer's Odysseus, who spends a long time away from home and returns to find a lot of similarities but many disturbing changes on his estate.