No one knows the complete answer yet, but dream researchers are learning more and more about the reasons why we tell ourselves stories as we sleep, and how these tales reflect and relate to waking life. Dreaming is a product of the brain and its activity. Whether a person is awake or asleep, the brain continuously gives off electrical waves that can be measured by an electroencephalograph. At most times during sleep, the brain waves are large and slow. But at certain times, they become smaller and faster.
Most dreams occur in REM sleep.
During REM sleep, the pathways that carry nerve impulse from the brain to the muscles are blocked. Therefore, the body doesn't move much during dreams. The cortex is stimulated by neurons that carry impulses from the part of the brain called the brain stem. Traditional psychologists and psychiatrists might say that dreams are the arena in which we parade and encounter fears and wishes banished from daytime thoughts. Freud believed that the brain was incapable of producing its own energy and used neurons as reservoirs to store energy from other sources, primarily from sexual and aggressive drives.