I dream to unleash my unconscious desire to argue with my annoying coworkers.
We dream to process memories, to remember important information, get rid of irrelevant information, and process the bad stuff.
Some believe we dream just to keep outside stimuli from awakening us.
This is what Freud proposed. It was part of his psychoanalytic theory. The objects in the dream are references to the previous day's experiences. These experiences are latent dream thoughts. Freud believes in our dreams we can act out behaviour, often said to be aggressive or erotic, that are taboo in real life.
The Bayesian brain/predicting processing paradigm, our dreams help us 'upgrade' our model of the world.
In addition, our brain will inhibit the motor neurons to prevent us from moving around too much.