Fairy tales are obsessed with hunger. There’s Thumbling, Jonah, Red Riding Hood, and Zeus's siblings, all gulped up only to emerge unharmed one way or another. In many stories, In stories from all over the world, parents threaten their children that some boogeyman will gobble them up if they don't behave.
In Hop o' my Thumb, the ogre hungers for the flesh of children. In Jack and the Beanstalk, the giant chants "I smell the blood of an Englishman . . . I'll grind his bones to break my bread." These man-eating giants hearken back to monsters such as Polyphemus in the Odyssey. Hansel and Gretel's witch is the same character. The evil queen desires to eat Snow White's heart. In Perrault's Sleeping Beauty, the second half features the heroine's mother-in-law attempting to eat her and her children cooked with sauce piquante.
And on the other hand there are stories where people are tricked into eating human flesh, especially the flesh of their loved ones - as in The Juniper Tree and some older versions of Red Riding Hood. In the Vietnamese story of Tấm and Cám and the Greek myth of Philomela, it's the hero tricking the villain into cannibalism.
There's one theory that the frequently-digested Thumbling is a story related to how children process the concept of pregnancy and childbirth.
This motif of being eaten and escaping appears in other tales, like Red Riding Hood and The Seven Kids.
Earlier theories suggested Red Riding Hood was a myth-like tale of rebirth, with the girl as the sun and the wolf as the night. That school of thought has now been largely discarded, and it's more popular to read it in sexual terms, perhaps as the devourer eating a lover in order to possess her completely. Hunger in fairytales is often a stand-in for sexual desires.
There are other factors behind the stories, though. I think it's partly ancestral fear, the fear of a bigger predator snatching you from your cave.
It could also be a way to face the taboo. In the 1997 article “Incest in Indo-European Folktales,” D.L. Ashliman points out that “many fairy tales owe their longevity to an ability to address tabooed subjects in a symbolic manner."
So, along with stories containing abuse or incest, there are stories like The Juniper Tree where people, even parental figures, turn to cannibalism.
Perhaps this is also where the heroes taking harsh revenge come from. In a story, you can dance the villain to death in red-hot iron shoes or send her hurtling down the street in a barrel lined with nails.
There are some beliefs that eating your enemy - usually in a ritualized ceremony - will give you his strength, courage or life force.
The Iroquois and Aztecs would do this with prisoners of war. The Sawi (Sawuy) people of New Guinea would give the victim's name, and thus his life force, to one of the villagers.
In Tanzania and other areas of Africa, some superstitions hold that albinos are magical and their bodyparts can be used in talismans or potions.
In Europe, human fat, flesh, blood and bones were consumed in medicines until around 1750.
Consuming the life force would be the goal of Snow White's evil queen, who seeks to eat her stepdaughter's heart and once again be the fairest in the land. Similarly, in Norse mythology, eating a dragon's heart gives Sigurd the power of prophecy.
Civilization vs. Barbarism
In The Irresistible Fairytale, Jack Zipes says, “Almost all cultures have cannibalistic ogres and giants or dragons and monsters that threaten a community. Almost all cultures have tales in which a protagonist goes on a quest to combat a ferocious savage. The quest or combat tale is undertaken in the name of civilization or humanity against the forces of voracity or uncontrolled appetite.” (page 8.)
In The Brothers Grimm: From Enchanted Forests to the Modern World, Zipes says something along the same lines: "Though each one of the Tom Thumb tales differs, they all focus on the same major concerns of The Odyssey as discussed by Adorno and Horkheimer: self-preservation and self-advancement through the use of reason to avoid being swallowed up by the appetite of unruly natural forces."
This describes the quests of Hop o' my Thumb, Jack, Gretel, and others. All three of these tales begin with families in extreme poverty, on the verge of starvation.
They begin with the hungry parents doing the unthinkable and abandoning their children in order to keep more food for themselves. Hunger thwarts the heroes again when birds eat their breadcrumb trail. Finally, they face a force trying to devour them. The tale reaches its happy ending when the heroes succeed, and in many cases even turn the monster's tools against them.
This website is based on my research into folklore.