My theory is that the brain is still active whilst asleep trying to store the important memories of the day into long term memory whilst filtering out the unneeded information. This sort of brain activity is interpreted by the brain as sensory input which creates the dreams.
Evidence for: Random activation hypothesis, learning theories of dreaming, awake brain surgeries where parts of the temporal lobe are stimulated and a memory is triggered to the patient
Problems: why it is so easy to forget dreams if they are supposed to be useful unless if they are sent straight into the unconscious as to aid processing (ie if the situation happens you don’t need to consciously process it so you find the adequate action and perform it faster).
Another problem I find is why the brain doesn’t encode smell/taste. A possible explanation is that its very hard to remember a smell/taste when the stimulus is not there, however vision and sound is easier to remember (we have an inner eye/ear that we use for cognitive processing but no inner nose/tongue). Touch is a strange concept as I swear in some dreams I can feel stuff, but that could just be the brain filling in the gap in the dreamstate.