Can be built outside.
A bed is used to instantly log off, there's a 20 second timer otherwise. To do this, right-click it and then chose the option to Sleep.
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.