Must be built inside a House.
A bed is used to instantly log off by right clicking it and then chose the option to Sleep. There's a 20 second logout timer to leave Salem otherwise.
Sleeping in a bed will increase your rate of inspiration; the better the bed the more extra inspiration you get while logged off.
Sleeping Overhaul (Salem Patch V1.1.3): Beds now cap the maximum amount of inspiration that can be gained in a single sleep session. Leafy Beds generate no more than 100,000 Inspiration, Simple Beds generate 250K max and a Grand Beds caps you at 500K.
Sleeping in a bed will reset your Insanity to the lowest point of your current Madness level after 8 hours of sleep. Beds will not lower Madness levels unless you go to sleep with a Teddybear as well.