The challenges of space flight often overlap with earthbound challenges; like when we solved solar panels for satellites, we got the same for earth.
When we developed microchips for Apollo, we got the same for here. Control systems for clean water etc.
Filtration filters urine in orbit, allow villages to filter contaminated water, etc...
Those things might have Eventually been done anyway, but spaceflight projects accelerate those challenging solutions faster/better/cheaper.