Doing anything in space is dangerous - you're removing yourself from a planet where there's gravity to keep your feet on the ground, and air for you to breathe, and deliberately putting yourself somewhere neither of those things exist. But even going to sleep is a life-threatening event for an astronaut.
Whilst we sleep, staying mostly in one space, we exhale carbon dioxide. Because of the lack of gravity to affect it in space, the carbon dioxide just stays where it is, and can slowly form a bubble around the astronaut's head, displacing oxygen and eventually causing asphyxiation as it's breathed back in. Most astronauts combat this by sleeping underneath ventilation fans to keep the air moving and eliminate the risk. As if there weren't enough to worry about already!