Over the years there have been numerous theories offered about why we dream. Many believe that it is to train our brains in a safe environment. Almost like we go into a virtual reality game where we can make mistakes without any repercussions. This would explain why younger humans dream more. It would also make good evolutionary sense as it means we gain experience with no risk, thus ensuring that we are less likely to die.
Another theory that is commonly offered is that dreaming is a way of sorting our memories out. That when we dream we are storing some memories for the long term and discarding others as they are superficial or of little use. Again, this argument makes a lot of sense, as when you think about your dreams, they do seem to be based on recent memories, and the idea that your brain is sorting them out just seems to make sense.
Others believe that there is no master plan when it comes to dreaming and that it is really just the result of two biological processes, consciousness and sleeping. That while it may have some use, this was not why it come about. That in fact, dreaming is just as random and strange as dreams feel when we try and remember them.