A further issue that’s often overlooked in English-language discussion is
Russian-language books.
A lot of specialist scientific literature such as monographs only saw a single run of 300, 1000, or at best 3000 copies in the Soviet Union, and that’s it. If you’d missed it and didn’t have access to one of a handful of libraries that had it, tough luck. (To give an idea of what counts as specialist, the foremost textbook on general relativity, Gravitation by Misner, Thorne, and Wheeler, was translated into Russian in 1977 and had a single 3000-copy print run. The 1973 English original is still in print.)
Furthermore, when the Soviet Union fell, so for the most part did the publishing houses, and nobody knows where the offset printing films for the books went. So nobody can print Soviet books again without typesetting them from scratch, even those that weren’t rare. (Did you know that the new Russian edition of Gradshtein and Ryzhik’s special functions manual is technically a translation from Russian to English to Russian? Or so it says on the copyright page, anyway.)
In that environment, having widely available scans of books was absolutely vital; for those who teach students fresh out of high school who don’t necessarily know enough English, it still is. Today’s LibGen arose as an amalgamation of a number of those efforts from the early days of the Russian-speaking Internet.
One was maintained (unofficially) by people from the Department of Mechanics and Mathematics of the Moscow State University. Another was mirrored (unofficially) by a Moscow-based particle physics institute that until several years ago originated a large part of the Russian presence at CERN. I’m sure other Russian-speaking research centers contributed just as much or more, I’m just not familliar with that part of the history.
As Russian-language scientific publishing stagnated, and subscriptions to English-language literature by and large did not materialize (what with them costing most of a typical money-starved institute’s budget), obtaining scanned and ebook versions of English-language literature from Western acquaintances became more important. People gradually unified under LibGen’s banner, and here we are.
And yes, none of this ever got government support, as far as I know.