When you sleep your brain takes that chance to organize the day's, or past few days' events, and that partially explains why we have dreams. If you don't sleep enough, you should find it harder to think and focus due to the fact that the brain could not organize recent events, get rid of what it doesn't need, and store other things as memories. If you don't sleep, think of it as when you have too much unneeded stuff on your computer and never take the time to clean things up. Of course, that's only what we know, and sleep still is a large research focus.
This is what I have taken from the numerous SciAm and Discover articles on sleep.