If you ever take a psychology class, this will be a topic you discuss actually. I'm taking a psych class right now and we went over this a few weeks ago.
There are three different theories about why we dream: A) To process what happened during the day (problem-solving), B ) It's our way to let out our subconscious desires that we don't express while conscious (wish fulfillment), and C) They're the side effects of the neural activation that produces the beta brain waves during REM sleep that are associated with wakefulness.
I believe in all three, actually. I've had dreams that solve problems, ones that fulfill wishes, and ones that don't make any sense whatsoever so they don't apply to the first two.
I was also going to say what Zeph said, about the fact that we always dream and just don't remember them all.
From what I've heard, the reason we don't remember some dreams is because on the nights that we don't remember dreaming, we actually got a good night's rest. If you remember your dreams, you didn't sleep as deeply/peacefully. I'm not sure if it's a fact or not though, but it makes sense.