Sleeping in a bed will change the world time to Dawn when all of the players within the Minecraft world are sleeping. It will also set the user's spawn point to right .
More: /r/Minecraft wiki. Hence why, whenever we try to place a bed, it explodes because we can't ever rest in such places. Magic :D.