It’s basically naptime for the nerve cells in your brain as you dip into non-REM sleep. They do send out a few messages, but nothing much. But like so many other bodily functions, brain activity goes up during REM sleep, sometimes even more than during the day. Blood flow to your brain also goes up during REM sleep.
Your brain also uses your sleep cycles to consolidate memories. So staying up all night to cram for a test might be counterproductive.