When you are in a bed, your hitbox is essentially flattened. In low light, other players often struggle to see the "Leave Bed" screen or the player model, allowing you to log out or AFK safely without being spotted by raiders on multiplayer servers.