Oral traditions were the norm from the paleolithic until the advent of written language. Many societies had professional story-tellers, shamans, or witch-doctors whose jobs it was to pass their beliefs from the current generation to the next. Elaborate rituals, songs, and dances were developed to make the passing of information more accurate. However, with each generation, flourishes, drama, new characters were added to the stories to make them more interesting and exciting. Also, the stories may have been "retconed" to account for new knowledge and actual science. Each society's myths and legends diverged and evolved. Neighboring villages would often have very different stories about the same characters (gods). These differences were often the cause of strife between neighboring societies.
Sometime between seven and six thousand years ago, a different way of communicating appeared. It probably started out as codes for tallying, counting, and inventory. Such systems are seen in neolithic cave paintings. So, it takes no stretch of the imagination to assume that these systems would evolve into something more complicated. Instead of a picture of an antelope, a simpler symbol could be used to represent an antelope. Soon systems of writting evolved as pictographs. Each word had its own symbol. Such systems worked, but was tedious. A writer had to remember hundreds of symbols. It was someones life work to record stories with pictographs.
Someone long ago had the idea that instead of the symbol for an antelope (for example) actually representing an antelope. the symbol could represent the first sound in their word for antelope. Now by asigning syllables or phonetic sounds to symbols, the symbols could be strung together to form just about any word that could be spoken. The good thing about this was that you didn't have to remember hundreds of symbols. Now, just a few dozen of so was all you needed.
Now, the stories, myths and legends could be recorded very accurately. The next generation no longer needed to rely on a story-teller's memory. Rituals could be accurately described, so later generations would do them right. This is probably where the idea that the written word was infallable came from. The older the religious text, the more mystic it seemed. It was the right way, because a very old scroll said so.
However, not everybody learned to read. Books, scrolls, and tablets were not indestructable and they were not very often portable. So, a few learned individuals in a society, could now assume the job of keeping these texts safe, copying them, and reading them to the public. Today we call such people priests and scribes. They
Every major religion (that I can think of), today, has holy books. Most of the religions place so much importance on those holy books that the scriptures become inerrant. There's no room for new knowledge or revision. If new knowledge contradicts the holy text, often the new knowledge is rejected on the sole merit of an ancient scroll's claims. Science is often rejected because there was a man thousands of years ago who said something different. Whether or not that primitive man had accurate knowledge of the universe is almost never considered by the religious. The word becomes God and the word does not change (see John 1:1-2).
Without written language, there would be no organized religion. Since, science also depends upon the written word, we can thank religion for keeping written language alive. However, the trend that I see of religion becoming more fundmentalist disturbs me. Many religious claims, today, are being proven false by scientific knowledge. The more devout have reacted by placing even more importance on ancient writtings. Because there's more than one holy book, the different fundamentalists are starting to come into conflict. The outlook does not look good.
This planet is the only place in the universe (that we know of) that humans and other earth life can survive. If everyone does not work toward peace and tolerence, this planet could be in trouble. I don't believe that all religion is harmful. It's when the words themselves become more important than whether it reflects reality or not that religion becomes harmful.