It is not certain why we dream but dreaming is normal and everyone does it.  Some people say that they never dream and, although this is their genuine experience, it is more likely they have dreams but do not to remember them.  If people are awakened during their dream they are much more able to recall the dream.  Unfortunately this does mean that nightmares are quite often remembered, as they are more likely to wake the person.