The fundamental importance of R.E.M. Sleep. (Rapid Eye Movement)
REM sleep stimulates the brain regions used in learning. This may be
  important for normal brain development during infancy, which would
  explain why infants spend much more time in REM sleep than adults (see
  Sleep: A Dynamic Activity ). Like deep sleep, REM sleep is associated
  with increased production of proteins. One study found that REM sleep
  affects learning of certain mental skills. People taught a skill and
  then deprived of non-REM sleep could recall what they had learned
  after sleeping, while people deprived of REM sleep could not.
  
  Some scientists believe dreams are the cortex's attempt to find
  meaning in the random signals that it receives during REM sleep. The
  cortex is the part of the brain that interprets and organizes
  information from the environment during consciousness. It may be that,
  given random signals from the pons during REM sleep, the cortex tries
  to interpret these signals as well, creating a "story" out of
  fragmented brain activity. 


Source: link