The Internet Archive is not run by the US Government. It's run by a private non-profit organization, and paid for by donations.
Also, it's not actually 100% legal. It's sharing a lot of software and media that's still covered by copyright, but nobody cares enough to do anything about it (generally called "abandonware"). For example, I just found "Burnout 3 - Takedown" for the original XBox, a game from 2004. I can guarantee to you that that game is still covered by copyright.