I know the ancient world had libraries (most famously the one in Alexandria) but weren't they private collexions?
The idea of a repository of books where everybody has the privilege to use just by there virtue of being a citizen/resident of that country - how far back does that go?
I work in a library, so this is definitely a question which I am interested in as well.
What I can share is that the earliest recorded library that was open for the public in China would be during the Song dynasty (1190 - 1200), where the Bowen tower 敷文阁 which allowed scholars to freely browse its collection. [source: guang xin fu zhi 广信府志]