Yeah, in most situations you'd be correct. Short of the entire biosphere getting vaporized(basically only possible from a rouge asteroid or from a superweapon like a nichro-dyson beam), Earth will always be more hospitable than almost any other body in space.
The exception to that is that you can make habitats that are custom-tailored for life. If defense is your goal, in theory you can shield an o-neill cylinder from anything except black holes and neutrino beams(possibly dark energy beams as well, I don't know). Unlike Earth, which would be very difficult to shield from a relativistic kill missile, unless they are less than a couple light-hours away, you can simply slightly alter your course randomly and that will prevent any targeted weapon from being able to hit you.
Guided weapons can be taken out by the fact that they have to be slower and have much more complex machinery. A simple perimeter defense machine gun(which you will have anyways for macro-meteorite removal) should be enough to take out the guidance systems.
That pretty much only leaves area attack weapons. You'd have to custom tailor your defense to each type of weapon, but I can't think of any you couldn't defend against. For example:
Biological weapons are no threat, your atmosphere and water systems are scrubbed anyways.
Massive nuclear bombs are most harmful due to their radiation and magnetic fields in space. But you're likely to have your habitat surrounded by your water supply to shield from cosmic rays. The magnetic field can be removed as an issue by having the hull made of superconducting material, as space is cold enough to keep several current superconductors operational.
Psychological weapons can be avoided because your entire station is a faraday cage, your enemy has no way to propagate information you don't want inside it.
But if we wrecked Earths environment, doesn't that mean we'd have the same issues there? No, not really. Your station can much more easily be climate controlled. Excess CO2 can be scrubbed for fertilizer and air, or just jettisoned from the station. Heat management is as simple as controlling the stations albedo and available surface area for radiation.
Keeping a space station running is way easier than keeping all of earth running. Even when scaled up to the size of Earth, it's wildly unlikely you will be dealing with fossil fuels on the scale Earth is. The biggest issue on the station will be biodiversity and food chain mangement. We don't know how a ton of vital critters react to space or differential gravity, so it's pretty likely we will have to alter species to adapt them to the station. My personal favorite examples are spidercrabs that magnetically walk around the outside hull in the vacuum of space in order to repair the hull. My second favorite is wifi-bees that use the same algorithm as your Roomba to methodically pollinate all the flowers. My least favorite is the flesh eating bacteria that we will have to make to deal with all the dead biomass.
Edit:also you can't defend against vacuum decay unless you are willing/able to wrap your station in dark energy. But if you can do that, you can protect against any weapon, flat out. Because that allows you to causally disconnect yourself from the rest of the universe, basically like a pocket dimension.