One proposed purpose of dreaming, of what dreaming accomplishes (known as the mood regulatory function of dreams theory) is that dreaming modulates disturbances in emotion, regulating those that are troublesome.
Writers are shameless. We plunder our life for creativity, not even our dreams escape.
The above article is fascinating. Do dreams regulate our moods? This struck me: "dreaming diffuses the emotional charge of the event and so prepares the sleeper to wake ready to see things in a more positive light, to make a fresh start."