The bed is an interactable object found in every inmate cell. You can also find them in infirmaries, guard quarters, and maintenance rooms (however you can neither take bed sheets nor tuck in Bed Dummies in those beds).
By sleeping in a bed, you are able to replenish health and stamina to great extents. Also, by facing the bed and holding [interact], you can obtain a bed sheet. Do this again and you will get a pillow. Beds without bed sheets or pillows will respawn new sheets and pillows when morning roll call starts. Like toilets, beds cannot be moved even though they appear disconnected from the floor.
When you have gotten to your cell at Lights Out, you can sleep in the bed to speed up time until Roll Call. All players in Multiplayer (The Escapists 2) must be sleeping to accelerate time, but take note that this will only work on your bed in The Escapists 2. If you want to escape at night without triggering a lockdown, you can tuck in a Bed Dummy in your bed (while the player wears a Guard Outfit). Do this by holding the Bed Dummy and using it on the bed. Note that both the pillow and sheets must be present on the bed for a dummy to be placed. For more info, see Bed Dummy or Lights Out.
In The Escapists 2 another thing is if you are low on health or stamina, you may use the bed to speed up regenerating your health or stamina. It is not as fast as eating or showering though so if those are also close to where your are chose that over sleeping in bed. Neither will this speed up time in any way.