One hypothesis:
Dreams seem to help us process emotions by encoding and constructing memories of them. What we see and experience in our dreams might not necessarily be real, but the emotions attached to these experiences certainly are. Our dream stories essentially try to strip the emotion out of a certain experience by creating a memory of it. This way, the emotion itself is no longer active. This mechanism fulfils an important role because when we don’t process our emotions, especially negative ones, this increases personal worry and anxiety. In fact, severe REM sleep-deprivation is increasingly correlated to the development of mental disorders. In short, dreams help regulate traffic on that fragile bridge which connects our experiences with our emotions and memories.