The player may sleep by approaching a bed and interacting with it. This may not be done while in combat stance, so you will have to wait a couple of seconds until the character sheaths its weapon.
The main use of sleep in the game is to refill your HP. Every second the character is lying in bed, health will be regenerated at a steady rate.
Another use is to hasten the passage of time. Normally a minute in the game passes every about 6 seconds in real life. While asleep the rate is sped up to approximately 2 game minutes per second.
NPCs may also go to sleep, although this is mainly scripted by the day/night cycle rather than due to fatigue.