Sleep is composed of two stages: REM (Rapid Eye Movement) and non-REM. The former helps in mental consolidation while the latter helps in physical repair and rebuilding.
No wonder when one wakes up with an alarm clock after 5-6 hours of sleep, he/she is mentally irritable throughout the day (lack of REM sleep).
And if somebody has slept for less than 5 hours, the body is in a complete physical mess (lack of non-REM sleep), the person is tired throughout the day and immunity is way down.