I think the other answers which mention electrostatics capture the physics behind things being rigid correctly. However, I wanted to specifically point to your question of "why are they rigid when they're mostly vacuum?" I'd like to draw your attention to Guyed Masts:
A Guyed mast is a tower whose rigidity depends on several guy-wires surrounding it. If you're treating the mast in the picture above as a rigid structure, you have to include the guy wires too. If you didn't include them, the tower would flex and collapse. And if you look at the whole structure, almost all of it is empty air between the wires.
WhichThis points to why things are rigid. If the electrostatic forces between atoms isare configured into a stable configuration, like how the mast with guy-wires is stable, then it can be rigid even though most of it is empty space. Its It's the structure which makes things rigid or not.