This would have been the job of the national archives and/or the national library.
Where I live, the government has a law stipulating that one copy every published material has to be submitted to the national library. I suppose a similar law exists for a lot of other countries, and extending this law to non-print media (like movies and TV shows) shouldn’t be controversial.
Regarding material deemed harmful and/or illegal, I think it should still be collected, but access would be restricted. If need be, access could be restricted to “premises-only” like what is done in a lot of university libraries.
Having this online library of material doesn’t have to mean that pirates have to be stamped out. I think this works best with the pirates keeping the government-sponsored media library honest.
However, what I think would be more plausible is an offline library of all the media that country has produced, with limited off-premises access afforded to researchers and others. That much, I think, would be allowed by the real powers that be.
That last paragraph of yours just made things click for me.
I’ve been wondering what kind of government will potentially do this. While it’s a pretty good idea in general, I don’t think any government will be able to shoulder the costs while earning the ire of the companies (media companies, etc.).