Our brain composes our dreams through many areas of brain activity, using different sources of information as well as many ways of connecting these memories and experiences.
This brain activity integrates genetically programmed processes that include survival related issues, with recent experience and new information, and with what is already stored in our brain.
It is now known that the limbic system is the one that is most active in dream creation, it is the one that directs our dreams, and since the limbic system is the one that specializes in dealing with our emotions and our emotion related memory, we can expect our dreams to be filled with the emotional issues that we need to deal with at the time. That is why our dreams are composed with lots of emotionally charged memories like anxieties, negative things affecting our self esteem, feelings of loss, trauma (physical and psychological), etc.
It is interesting to acknowledge that the same neural networks that make associations and plan our actions while we are awake, direct our brain activity when we sleep. When we sleep and dream these networks have minimal sensory input from the outside world, so there is almost no constrain to activate any possible combination of neural patterns.
This lack of constrain from a conscious-logical way things should happen, is the reason why there are “magical” appearing and disappearing of things, people, places and surroundings in our dreams, yet it all flows fluidly as it creates meaning of it, even if it makes no conscious-logical sense.
The purpose of dealing with our emotions in our dreams is to make sense of the world around us and how we fit in it.