Religion has played an essential part in human history. The earliest remains of human settlement are thought to be religious sites - Göbekli Tepe and Nevali Çori, both in Turkey, are prominent examples. The institutionalization and centralization of religious belief was an indispensable tool of another essential part of human history - that of governance. From the household governance of parents teaching their children not to insult the gods by lying to a king utilizing priests to help overawe his subjects by asserting divine right, divinity was a tool for encouraging submission as much as it was a tool for finding personal peace.
The prominent religions of today were not vacuum-sealed from the world before their genesis. Christianity's cradle in the Levant gave it traditions from the religions before it, most heavily Judaism. Considering that Christianity began as a Judaic heresy, this is not surprising. Nor is it surprising that as Christians radiated from their holy core and generations begat further generations, Christianity changed as its population did. The Christianization of the Germans is the starkest example of this - priests and monks from the viking-ravaged British Isles ventured into a land unconquered by the Romans to confront the gods that reigned there, and many paid for it with their lives, the most prominent being Saint Boniface. Their methods of conversion were varied; the strength of the Germanic gods were tested by cutting down sacred trees, when the priest was not struck from the heavens the Germans would consider his god greater; bonfires were built by Christians and by Germanics and the first to catch fire naturally had the stronger god; adopting Germanic culture into Christian culture as seen with the Christmas tree and the names of days; even old-fashioned debates between chieftains and priests would end up converting a tribe. But by far the most effective tool the priests had to convert the Germans was Charlemagne.
Charlemagne was the king of the Franks, a Germanic tribe that would become the progenitor of France and Germany. He was very much what you would consider a barbarian, but he was also a Christian barbarian. Very concerned about his earthly power, he was also concerned about the afterlife, and he saw Christianity as something to help on both fronts. Having God on your side was a very convincing argument to make, and Charlemagne utilized priests to spread word of his grandeur and power in the same breath as God. Charlemagne was distressed by the martyrdom of Saint Boniface, as he was a mentor for him in his youth, and focused his energy on conquering the Frisians, the Saxons, the Bavarians, and all the other pagan Germans. With the hammer of Charlemagne backing their word and ensuring their safety, Christianity had free reign in converting the Germans. The Pope would eventually crown Charlemagne Emperor of the Romans, making him the final authority on earthly affairs - at least, that's what Charlemagne thought. The Pope thought this action made Charlemagne answer to the Church, and it would be this fundamental misunderstanding that would shape the history of Europe. (On a tangent, further complicating the matter was the very confused and angered empire based out of Constantinople that we know as the Byzantine Empire, but what called itself the Roman Empire. This confusion was based off of a religious disagreement turned political that fractured Christianity into what we know as Roman Catholicism and Greek Orthodoxy.)
Such adaptation of religion is not specific to Christianity. When the Muslim Arabs conquered Central Asia, they conquered a profoundly diverse and literate land with a dynamic cultural interaction between the Persian urban population and Turkish nomadic population, flavored with technology from China, mathematics from India, philosophy from Greece, script from Syria and trade from Russia. Central Asia was very much the center of the world at this point as Nestorian Christians rubbed elbows with Buddhists as Zoroastrians argued with Hindus. (The conflict between Zoroastrians and Hindus is another interesting tangent - Avesta-speaking Zoroastrians were monotheistic and considered the Vedic-speaking Hindu gods false deceivers, but both groups were part of the Aryans that populated Iran and Northern India and their religion split as the two areas came into conflict.) The Arab Muslims that conquered the region were not able to convert the populace, but they were able to govern it - for a while. Heavy-handed attempts to crush the indigenous culture by executions and book-burning backfired, and Central Asians would eventually be a driving force to overthrow the Umayyad caliphate and install the Abbasid caliphate, one more in line with their beliefs - notably a more philosophical and less doctrinal approach to religion.
Similar to how there was a political place for Christian holy men, there was a political place for Muslim holy men. After all, what better guide is there to live your life than the word of God? The interpretation of holy works by holy men was of dire interest to both commoners and nobility, and similar to how Charlemagne figured out he could use the priesthood to spread his own power, Caliph Al-Mamun attempted to persuade the ulama to support his efforts to centralize power. The ulama was inherently a conservative organization, and Al-Mamun's embracing of Mutazila was considered heretical. Mutzaila could best be interpreted as believing logic is a suitable way to interpret the word of god, as opposed to faith. Such a belief contradicted the tenet that the Koran was infallible, which was unacceptable to a large portion of the ulama. The most prominent of the resistance was Ahmad Ibn Hanbal, a scholastic titan with immense respect among other members of the ulama and the population. For his refusal to bow to the authority of the caliph and his argument emphasizing reason, Ibn Hanbal was tortured for a lengthy amount of time. His refusal to recant his beliefs and subsequent martyrdom was a foundation event in traditionalist Islam. It was also a terrible backfire on Al-Mamun's part and would have crippling consequences for proponents of reason and liberalism in the Muslim world.
The infallibility of the Koran, similar to the infallibility of the Bible, is a question that supporters of infallibility will argue has been answered in the past and requires no further guesswork. The method of constructing the Koran and the Bible brings up obvious concerns with that belief - the Council of Nicaea was called almost 300 years after the death of Jesus to decide which religious texts would be included in the Bible, and the Koran was written down for the first time 20 years after the death of Muhammad. Moreover, hadiths - miscellaneous statements and phrases made by Muhammad and his closest followers about how to live life in a righteous fashion - had exploded in number as time went on, and Islamic scholars had to meticulously verify each one to determine which statements were divinely inspired and which ones were misquoted at best and heresy at worst. The possibility of human fallibility through all this is obvious, as is the opportunity for political influence in determining what is divine and what is rebellion.
The disagreements in Christianity over how to interpret the Bible are what spawned the Great Schism between Roman Catholicism and Greek Orthodoxy and the subsequent Cathar, Hussite, Calvinist and Lutheran heresies. Such disagreements also happened in Islam, most prominently between Shia and Sunni but also within Shia and Sunni. The message of God is thus muddied at best, and the simplest way to explain these differences is the effect culture has on religion - not just the effect government has on religion, but the innate cultural practices that shape belief. For example, as Central Asia became progressively more Islamic and the cosmopolitan court atmosphere started to calcify into orthodoxy, the masses turned greatly to Sufism - an ascetic, universalist sect focused on one's personal relationship to God and less on the doctrine and dogmatism of the ulama. This was an attitude largely shared by Protestants who rebelled at the Biblical monopoly of the Catholic church, and further exemplifies the kaleidoscope of faith both religions have.
One cannot talk about the role of religion in society without touching upon the role it played in war. Zealotry is a powerful weapon, especially when paired with the ancient human traditions of raping and looting. The role of Christianity in the Crusades and during colonization is of central importance, as the role of Islam in the Arab conquests and modern insurgencies - you cannot fully understand the subjects at hand if you do not know the background, and you cannot discard the effect that religious justification has on war. But at the same time, you cannot plant it all at the feet of religion - European Colonization used religion as a justification to subjugate and annihilate the Aztecs, but the initial leap that got them to the New World was to get around taxes put up by the Ottomans on goods from the Orient, not to mention the taxes installed by all the other fiefdoms between the Ottoman Levant, India and China. That less money would go toward the Muslim Ottomans was important, but not as important as more money going toward Christian Europe.
When religion was used as direct justification for war, it was not done for the first time between Christians and Muslims. We touched earlier on the conflict between Zoroastrianism and Hinduism, and how they essentially believed in the same beings, but each worshiped a different side in the cosmic battle. Similarly, when Judaism was struggling for power and influence in the Levant, they painted the opposing Samaritan, Sumerian and Phoenician gods as false prophets and evil beasts. You can observe this by how we perceive the names of their gods - Leviathan, Moloch, Baal, Behemoth, et al. As the Jews fought these groups to establish Israel, they painted their mortal fight with other humans as an extension of the fight of their true God against the false gods of their opponents. This was nothing new - as the Assyrians were founding their empire, they would regularly steal the religious statues and totems of the defeated and bring them back to their capital of Nineveh, showcasing the captivity of their enemies' gods and the corresponding subjugation of their people. It was this doctrine that led to the Biblical Babylonian captivity.
What lesson is to be gained here? The role of religion is of historical significance for humans, though humans perception of religion is not absolute. The methods of worship, the rules of worship, and the point of worship are as fluid and intangible as human willpower, and as prone to being mistaken or malicious. That there are people that are violent toward non-believers is nothing new; the difference is that we now have more extensive documentation than in any time in history where we can see similar strains pop up in all religions and cultures. There are the obvious superficial similarities between religions, but just as important are the qualities people share across cultures - particularly, how people become less materialist and more violent when faced with poverty and no hope of secular success. Assuming that everyone in a religion has the same belief structure is simplistic and erroneous, and does a great insult to how imaginative people can be. That this imagination can lead to mass murder being repeated indefinitely is a constant tragedy, but group punishment is something that belongs in a different culture and a different era than modern-day America.