There is no “scientific explanation” for why we dream, though there are a lot of speculation that sometimes reaches the media and creates a general impression that the riddle is scientifically answered (for instance, to sort our memory), but there simply is no scientific consensus of why we dream.
Personally I think we dream for several reasons, just like we think for several reasons, and that is the problem when people more or less scientifically tries to prove why we dream. We do not dream for one particular reason. Our consciousness has an image producing capability, and we use it to solve problems, remember something from our childhood, write a piece on an internet forum, tell a story for our children, and so forth. In the same way, our unconsciousness has an image producing capability, and it is used to, say sort the impressions from the day’s waking life, ventilate sexual frustrations, and at times it is only unintelligibly forms that our conscious interprets as images as it is waking up, and so on and so forth.
You cannot say: We think to solve problems, because everyone who has an awareness of what is going on inside of him or her while awake, knows that that is not the conclusive reason. And you cannot say: We dream to sort our memory, because everyone who has an awareness of what is going on inside of him or her during sleep knows that that is not the conclusive reason.
For instance, I’ve been writing down my dreams since 1992, it is about two thousand dreams, and I could show you that dreams definitely bear a psychological meaning; for instance, in the nineties I lived in a bad relationship, and this is quite obviously reflected in the dreams in such a clear language that it is incomprehensive that I did not see that at the time. This is only an example, in the material there are numerous examples like this, not occasional dreams, but dream series that without doubt is “discussing” a particular psychological issue with recurring figures, places, themes and so on; and when that issue is not current anymore, for one reason or another, the particular dream series cease. So there is an obvious psychological meaning to dreams, which has been shown numerous times during the 20th century; however not scientifically proven because dreams are spontaneous and you cannot in any show what a person will dream next.
What I can show convincingly is that dreams are psychologically meaningful, but I don’t think that that is the only function of dreams. With my experience there is no doubt that that is a function, but dreams may also have a, let’ say more biological function. Like our consciousness is a container for all sorts of activity with different purposes, the unconsciousness is too. So we are like the blind people in a village with an elephant; one says its hard and smooth, another argue that it is more like a tree trunk, the third can’t understand why the other two won’t recognize an ordinary tail. It seems difficult to understand that an elephant be be this-and-that; natural phenomena like elephants and dreams mustn’t necessarily be either-or.
So while one psychologist studied tusks all his life and wrote books on its characteristics, the latest speculation from a contemporary university somewhere about tree trunks does not mean that the psychologist’s theories was nonsense all the time, nor that there’s a tree in the village.