Not so long ago, even a leading sleep scientist could joke that the only known function of sleep was to cure sleepiness. Over the past decade, researchers have been pinpointing the important purposes sleep serves – and the bad things that happen when you don’t get enough of it.