The library costs 20K gold to repair. It takes 6 hours to finish, or 6 gems. Once you have repaired it, you can fill in chapters in any of the 15 books in it. To fill in a chapter, you need to hatch the required monsters. Filling in a chapter gives you great rewards. A legendary monster called The Keeper will give you a tutorial on the library.