In the first place, different religions hold scripture to different standards of truth. Jews tend to consider their Bible more literally than Christians do. Different sects within the religions hold certain aspects to be more important than others.
But it took me awhile to really wrap my brain around exactly what scripture was. Sure, they were originally folk tales passed around and eventually got committed to paper, and then collected into books. But how do they decide what works to include in the books and what to keep out?
This is where the concept of the zeitgeist becomes instructive. The whole flock of believers collectively determine what the religion is. It’s just a larger version of the sorts of small tribal cults that happened before civilization arose. If the tribal leader “had a revelation,” that revelation became part of the spiritual ‘record’ of the tribe, being passed down through the generations as long as the tribe lasts as a real thing.
Storytellers cross-pollinated with each other over the course of history and stole ideas from each other. Eventually certain themes that held more power than other themes to convince, inflame, enlighten, and otherwise drive wisdom and belief, well they just became common features of tribal myths. And with the rise of agrarian empires and cities and organized polytheistic common faiths, these myth-ideas just got mixed and remixed and massaged to inspire new generations of farmers and warriors. Technology and social organizations changed, but what inspires people throughout history didn’t change quite as fast.
Finally methods of publishing refined enough to create lasting records of these myths, and the organization of the forms of ritual and worship grabbed onto this technology and used it to promote an orthodoxy. This is the beginning of the idea of scripture, that everybody needs to be on the same page regarding spiritual truth.
Social organization simply required that everybody know their place in society and what constituted right and wrong behavior. It was just really really dangerous to go against these norms.
These days, this kind of social cohesion is no longer required, but myth still possesses the ability to inspire belief, and the stories we enjoy today, well we enjoy them precisely because they remix these mythic ideas. Scripture is still just as powerful as it was back then, it’s just that it’s so old and was written to meet the spiritual needs of Bronze Age peoples. But you can still read them and be inspired. Inspired people tend to go farther than reasonable people would for their beliefs.