In my view, the primary reason public libraries were created was to provide the public with free access to informational and culturally-relevant media (books, newspapers, movies, audio, etc). Previously, a library's effectiveness in fulfilling that mission was naturally limited by the need for the library to acquire physical copies of every article of media they provided access to, and by the natural geographical restrictions imposed by the need for members to physically travel to the library to view, check out, and return those articles. These limitations made it relatively easy for libraries to coexist with copyright law, as libraries would never be able to compete with the convenience of personal ownership of a physical copy of media.
With modern, digital media, such physical limitations are no longer present. Were it not for copyright law preventing digital media from being acquired and loaned out the same way that physical media are, it would be rather easy to build a public library system which would fulfill its mission so efficiently and with such convenience that it would supplant the need for personal ownership of media for the vast majority of people.
Imagine a national library purchasing 100 copies of a movie, then instantly "checking it out" to you when you stream it to your phone, and "checking it in" as soon as the movie finishes playing or you pause it for more than a minute or two. Such a system could be many orders of magnitude cheaper than our current public library system, while at the same time being far more convenient. They could put Netflix, Amazon Prime, Hulu, and Disney+ out of business overnight. Now apply the same system to books, music, magazines, etc. Why would any significant number of people bother buying any of those forms media ever again?