Dreams are very useful. In the relaxed state of sleep, our minds can reshuffle the events of the day, sometimes bringing important themes to light, sometimes just depositing extraneous thoughts into the rubbish bin. It could be compared to a nightly optimization of our mental hard disk, giving trillions of neurons the opportunity to clear the mind in preparation for the next day.
One of the extraordinary things about dreams is that while we are dreaming them, they seem real. It’s a great relief to wake up from a nightmare, when we may have done something awful, or someone may have done something awful to us, and then to discover it was just a dream. Buddhist teachers point out that precisely the same process is happening in our waking life too – we think it is real.