The most efficient way to colonize space is with self replicating robots/factories. Human settlement is probably going to be more of an afterthought, or along the lines of on-site repair and teleoperations personnel for the robots doing the heavy lifting. The concept of slave labor in orbital mining colonies doesn’t make much sense outside of science fiction.
Once a certain critical mass has been reached in terms of having systems that can convert raw space materials (asteroids, lunar regolith, and so on) to more useful configurations of their raw elements (metal, solar panels, breathable air, and so on) it will make more sense to set up habitats. These will probably be between planets, not on planets.
This will have some positive consequences and some negative where x-risk is concerned. On the negative side, access to high energy weapons is almost an inherent part of being in space, since it is relatively easy to create high velocity projectiles (gravity alone adds huge amounts of energy to any sizable object, including the sun’s gravity), and sterilizing the entire planet will be more plausible than even nuclear weaponry.
On the positive side, we will have decentralized our population and have the ability to survive if the earth itself is rendered uninhabitable. We will also likely develop more easily decentralized types of manufacturing tech which will protect against supply chain disruption, thus reducing economic paths of civilizational decline.
It is also worth noting that the earth’s carrying capacity can essentially be extended, guarding against overpopulation, by returning refined materials and/or energy from space, once the level of off-planet industrial growth hits a point where it becomes profitable to do so. So even from the perspective of people who want to stay on earth forever, there is incentive to develop this. You can also use it to guard against asteroid impacts, but that’s a relatively minor gain compared to the rest of the picture.
You are forgetting the rocks, including metals and so forth that we know to be present there (and on the asteroids, which are an even more serious target). Lunar dirt and rock is about 10% aluminum, just like earth dirt and rock is, and just like stony asteroids are. Oxygen is the most abundant element in them, followed by silicon. Iron is also present in small (but inexpensively magnetically collectible) amounts in lunar regolith due to meteorite impacts from metallic asteroids.
The problem with earth is that as long as we stay here, we tend to only develop technologies optimized for this environment—which is small, crowded, and vulnerable. If you develop technologies for the Moon, that same approach will tend to work almost anywhere in the universe. You wouldn’t stay Moon-only for long.
We do have approaches that could be used, but they aren’t mature because we don’t have a need, thanks to plentiful water and water-based geology. For example, we have long known that you can convert any substance to plasma by raising the temperature to 10,000k and the dissociated ions can be separated by mass charge ratio (a la mass spectrometry). Efficiency in such a system would be tricky, but isn’t necessarily insoluble (might require that it be done at very large scale, for example). Energy efficiency itself is also somewhat less relevant given the abundance of sunlight.
The big issue with dragging our feet on space is more to do with astronomical waste than x-risk in my opinion. Every day we wait to build the first self replicating robotic space factory is another huge loss in terms of expected utility from economic growth. The chance of an asteroid impact probably isn’t high enough to rate by comparison to the missed gains of even a fraction of 1% of the solar output translated to meaningful economic activity.
I’m not sure expanding into space necessarily (in the “all else equal” sense) reduces x-risk, since space warfare has the capacity to be pretty brutal (impact weapons, e.g.) and the increased computational resources that would be granted by having a mature self replicating space industrial capacity could lead to earlier brute forcing of AGI. It’s probably important to control who has access to space for it to actually reduce x-risk (just like any other form of great power, really). You would certainly eliminate some x-risks entirely though (natural asteroid impact, virus that wipes out humanity, global warming caused by reliance on carbon based fuels, nearby supernova, etc.)