So whether it's via robot or human spacewalk (though a manned operation is even more expensive obviously) the issue is the prohibitive expense of getting to the Hubble to fix it.
So 'getting to the Hubble' is pretty low in price, all things considered. Now the hard part: building something that can fix the Hubble. Humans would be good at making repairs, but the SpaceX Dragon capsule doesn't have an airlock, so that won't work easily. Repairs might be doable by a robot, but I suspect the easier option would be to simply attach new parts to it to perform the broken functionality.
If you can build the new piece for $40m, that's $100m to add another 20+ years to the lifespan of this incredible piece of equipment. Heck, sounds like something Bezos might do just for fun and as a test for his New Glenn rockets.
Can Dragon 2 do what most capsules do and just cycle the capsule interior into vacuum then open the door? (With everyone in suits first, obviously).
Neither did the Apollo moon landers, or the Gemini missions where NASA first tested spacewalks. Instead they just depressurized the whole cabin, making it into one big airlock. Presumably this would work for the Dragon as well.
I think it's instructive that they never tried that with any of the earlier Hubble repair missions.
At that point you’d just launch a new one. Earth’s gravity well assesses a steep tax.
The key thing to remember when it comes to space is energy/momentum. Right now, the Hubble Space Telescope is 24,000 lb of mass moving at 4.7 miles per second. To get it back down to earth, you need to somehow slow it down. First, slow it down enough to reach the atmosphere and then protect it as the atmo drag slowed it the rest of the way. I don't even think the Space Shuttle, were it still around, would be capable of doing that.
Remote repair using a robot is a whole other issue, and I don't think we have the tech developed to do this reliably any time soon.
I think you'd basically have to engineer something from scratch, which is a big ask. It would be really interesting though! Imagine if you just left the robot up there, plugged in and on standby- ready to activate and do some repairs as needed. We should have one on every major satellite. Give him a box of spares, plug the remote into a 12 year old hopped up on adderall, mute the mic and watch it go.
However, figuring out budget (X-37B is a USAF asset, not a NASA vehicle), designing & constructing a robotic repair system that fits in the cargo bay, etc. would be nontrivial both in terms of price/ROI and the hopefully impending debut of the Webb telescope.
but, please, change my mind and fix it! =)
However, there is a HUGE amount of data still to collect from space-based telescopes. Even a crippled HST is a desperately wanted resource. It benefits us to have as many space telescopes as we can right now.