They learn to accept the fact that everyone will die, that bad people sometimes get away with horrible crimes and never go to jail, and that many of your good deeds will never be rewarded. It is my assertion that people who are religious do not want to grow up and accept life's negatives. They would rather deny the unpleasant realities of life, and cover it up with the patented fantasies that religions have to offer. In a sense, nearly every religion serves the same functions. Even the polytheistic religions of ancient Greece and Rome provided comfort for the believer.
Death is hard to deal with, even for non-theists.
It's not pleasant for us to think about being dead, rotting away, being eaten by bugs. It's hard to imagine not living. We all have seen death in one form or another before, and the horrible ways that some people and animals end their lives is too horrifying for many of us to want to think about. Religions comfort our feelings surrounding death. For our own deaths, religions usually offer a paradise or reward for making it through life.