For as long as people have recorded their history, they have told stories. In the days when people did not know nearly as much about the world as they do now, they made up myths or legends to explain events. The fairy tale was born from those stories.
Children and adults alike love a good fairy tale. In the archetypal story, good wins over evil, the bad are punished, the good prosper. The hero and heroine must go through trials to prevail, and magic and magical creatures usually appear, but in the end, the protagonist is victorious. Magic is generally the deus ex machina that saves the day.
A fairy tale may exist in several versions. One good example is Little Red Riding Hood. One version is strictly a cautionary tale. Red Riding Hood disobeys her mother, talks to the wolf and ends up being eaten by him. So end all bad children. However, another version of the story has Red Riding Hood being pursued by the wolf, who catches hold of her hood, which, being enchanted by the grandmother, burns his mouth. He goes headlong into the village well and drowns. Some versions have the wolf eating the grandmother but being killed by a hunter, who cuts the wolf open and rescues Grandma.
These stories may also often be sanitized so as not to frighten children. Sleeping Beauty in its original form had the Prince's mother cast as an ogress who eventually attempted to have Sleeping Beauty and her children killed so the ogress could eat them. The Disney version does feature the terrifying Maleficent, but once she is defeated and Aurora wakened with that fateful kiss, all is well forever and ever. They all live "happily ever after," in fact. The Disney version of Sleeping Beauty comes fairly close to the original, but many parents have deemed it too scary for their children.
The fairy tale is an important component in children's literature. Many modern themes in movies and television are derived from the fairy tale, in motif if not in plot. Modern people frequently use Cinderella as an example of any person or group with poor prospects that succeeded in spite of the odds. "Prince Charming" is the beau-ideal of manliness. The Shrek movie series probably does as well as any modern media in skewering the genre, but the jokes are much funnier when the viewer is familiar with the original tales. Still, the story is an ideal medium in which children can exercise their imaginations.
A complete collection of the most common fairy tales can be found online at classicreader.com. The fairy books compiled and edited by literary critic Andrew Lang are available there. He compiled these books in the latter half of the 19th century, and his books are required reading for any fan of fairy tales from around the world.