You dream in REM, when your occipital lobe is most active. Your eyes dart back and forth in your head and stuff.
There are random neuron firings going on while you sleep, for reasons unknown; some people claim that it's because the brain is addicted to perception, even when it rests. These neural firings then must be made sense of, because the brain likes organization. It's not necessarily true that the frontal lobe "turns off" during sleep as someone said earlier. This is simply a theory. But then again the entire brain basically shuts down for rest during sleep, and these firings keep it going.
I forget the name of this theory, but it's just that... A theory. There's no proof involved.