"... aiming for the moon and getting halfway there gets you further than if you just aim for the roof and only get halfway upstairs. People's achievements in life depend quite startlingly much on what they expect to achieve ...
[In myths and folk tales] you find all the troubles and problems of this modern age - any single one you care to name as long as it is archetypal - becoming timeless and distanced, so that you can walk round them and examine them without feeling helpless. This is where fantasy performs the same function as joking, but on a deeper level, and solves your problems while keeping you sane. It is no accident that the majority of folk tales at least have a happy ending. Most of them are very deep-level blueprints of how to aim for the moon. The happy ending does not only give you gratification as you read it, but it also gives you hope that, just maybe, a fortunate outcome could be possible. Your brain likes that. It is built to want a solution."
From Reflections On The Magic of Writing by Diana Wynne Jones.
See also this post.