Could you provide some examples of this as this is not my area of expertise.
Sure. Initially lorekeeping, recordkeeping, and subsequently writing (including hieroglyphy) were sacred arts within the purview of Shamanism and Priesthoods. This was true not only in cultures of Sumeria, but in far distant cultures as diverse as Celtic and Mayan civilizations.
Lorekeeping was considered sacred, stories handed down carefully from generation to generation (no doubt changing along the way), and then hieroglyphy appeared to provide a way to use pictures in representing ideas. However, only the priesthood and the family of the Gods were allowed to learn the art of representative ideation. That isn't what they called it, but in modern terms that is what it was. Eventually, these gave way to characters that formed words to convey ideas. But the origin of writing and character representation was religious for the purpose of lorekeeping, which was a religious office in every discovered ancient culture (afaik).
Papyrus making was not initially a trade for the general public, either. Gathering the materials, yes. Anyone could do that. Papyrus making was considered a sacred task. It was not a common writing medium, because the art of writing was not common. In fact, writing was taboo for all but the priesthood (counting shamen and druids as priests, who typically used stone or clay writing mediums). As with any technology, eventually the priestly duty was commercialized. For 1,000 years we lost the technology to replicate this once common writing medium. To this day, we have been unable to duplicate papyrus of the quality and durability present 2,000 years ago. We simply don't know for certain how they did it—although the prevailing theory is that the strain used differed from that available today. Pliny's Natural History outlines a method, but we haven't been able to replicate the quality.
It is an interesting topic to investigate. This should get you started if you would like to explore the topic in your spare time.
Gathering into large localized civilizations in ancient times only makes sense in a religious context. Otherwise, nomadic family groups are sufficient (and even preferred) to insure broad genetic diversity and keep from overly depleting food stuffs and other raw material in a given region. But the Gods (if you will) are obviously more favorable toward larger groups of their followers, grander offerings, etc. However, larger groups are poorly suited to nomadic lifestyles and food concerns quickly become a serious issue. How do you produce food for that many people? Grains are (over time) bred for maximum yield and irrigation ditches are dug. Water wheels and sluices are devised, carrying water for irrigation from great distances to water crops.
The first cities in human history were temple-cities. And this is not true of just a few cultures. The connection of "collections of large groups of people in very localized centers" to "a perception of religious necessity" is clear throughout history.
Without these developments it is highly unlikely (impossible) that sufficient diversity of ideas would ever have occurred within a given lifespan to produce the technologies we have today. The sharing of ideas in written form has allowed for us to build on the perceptions of those who are long dead. When attempts have been made to wipe out "heretical" schools of knowledge, the attacks have been leveled at the written word—because men die, but the books live on well past the men who wrote them.
So, while I understand villainizing religion for its historical attempts to destroy knowledge and those who possess it, in my opinion it is important to remember that the books could not have ever come into being in the first place without religion.
Respectfully,
AuldSoul