You have many of the same risks for a space habitat as you do for a Martian colony, but with the added disadvantage that all the resources required for construction & maintenance would need to come up from earth itself, or possibly a very large mineral-rich asteroid pushed into earth orbit; either presents serious engineering and logistical challenges. Mars at least offers raw materials in situ
that can be used to construct habitats, process fuel and breathable oxygen, and the soil, with some help from terrestrial microbes, might be able to sustain crops, and of course there's orders of magnitude more space to plant them. Plus, any extinction level event that takes out earth would also run the risk of taking out an orbiting space station as well. Mars is considered a somewhat safer prospect in that regard since it would be too far away to be affected by such a cataclysm.
OTOH, the idea of a larger "shuttle" system between earth and Mars has been proposed, and what you suggest sounds not too different from Buzz Aldrin's Mars Cycler