Dreams emerge from the events in our lives that we didn’t fully experience.
In the ancient Buddhist teachings, it is said that most people go through their lives resisting the things that don’t feel good (everything from scary people to a scary thought), and clinging to the things that do feel good (a sensual moment, the smile on a baby’s face).
In both cases, rather than just being with the moment and experiencing it fully, we use our free will to do something to it. Just experiencing it isn't enough. We feel the need to to resist it because we don't like it, or cling to it because we don't want to let it go.
The problem is, when we do this over and over throughout our lives, we end up with so many stored energy patterns inside of us, which the Yogic traditions call samskaras.
Think of samskaras like dams in a river. They block the free flow of energy. As we accumulate these samskaras in our everyday lives, we then give our minds the impossible task of trying to fix everything in the outside world so that we avoid all those things we resisted (because they hurt), and seek out all those things we clung to (because they felt good).
In general, we think that by replaying certain events in our minds, it'll somehow protect us from experiencing the painful events again, and help attract more of the pleasant moments into our lives.
What we don't know is that this is literally the source of all our suffering.
Day after day, we spend our energy trying to manipulate reality according to our stored energy patterns, rather than simply harmonizing with it.
When we dream, although our body is asleep, our minds are fully active, trying to control things, trying to fix things, trying to work through problems, all while you’re in there, witnessing the mind at work.
When you dream, your mind is simply trying to work out your samskaras, and ultimately make you feel good. What your mind doesn't know, however, is that you're in charge of feeling good, not it.
Live with substance!
When we're unwilling to fully experience an event, we push it back down with our willpower. This is the cause of all our suffering.