Since the beginning, as long as records of history have existed, so have the libaries to store them. For example, in a city in Babylon, clay tablets were found in mass amounts in one particular place, indicating a large collection of written works.
Many ancient rulers destroyed their own records, along with the conquest of war when adversaries purged these sacred documents.
After saving most of the records by the Han dynasty in 206 BC, a system was devolped which classified popular genres:
This messy system was honed down over time, focusing these broad genres into four main types:
Following the patterned flow of the Han dysnasty, libaries started to pop up all over the world, including Rome, Byzantium, Pergamum, Greece, and Alexandria. These establishments encourged the civil service system, which is a government formed of career civil servants.
Alexandria's library, which burned down around 50 BC, was the basis for Aristotle's library and philosophies. He also brought the idea of making copies of important books and tablets.
Over time, these specific libaries started to develop into a game of trust and loyalty. You borrow a book and you promise to return it. As you can see, we still use these fundamentals in our everyday life, whether that's relating to something small like borrowing a hair elastic from a friend or larger extremities that require more than just the trust and loyalty of a person.