While the above answer hits upon some good points, the cause of the Iran-Iraq War was a little more focused, and primarily involved the Shatt al-Arab waterway dividing the two countries along a stretch of border where the Tigris and Euphrates Rivers meet.
Borders in that region of the world are largely artificial constructs established by British and French diplomats at the end of the First World War, which also marked the final demise of the Ottoman Empire. There had long been friction between Iran and Iraq over the precise map coordinates for the border, with each arguing for placement of those coordinates in a manner advantagious to them.
Hostility between Iran and Iraq predates the Iranian Revolution by centuries, starting with the different ethnicities involved -- Iraqis are Arabs, Iranians mostly Persian -- and extending to the deep and intensely violent distinction between the Shia Muslims of Iran and Sunni Muslim ruling minority of Iraq (a situation radically changed following the 2003 U.S. invasion of Iraq, which toppled the Sunni-led government of Saddam Hussein).
Add to the mix the large populations of disenfranchised Kurds in both countries, all desirous of an independent Kurdish state and suffering from repressive Arab and Persian policies aimed at keeping them in place, and the seeds were planted for a major war. The Shah of Iran, who ruled since a 1954 C.I.A.-inspired coup d'etat deposed the democratically-elected presidency of Mohammad Mosaddegh, supported Kurdish aspirations on the Iraqi side of the border as a bargaining chip in his efforts at establishing the border separating the countries in an advantagous position for his nation, a position that would give Iran preferable navigation rights on the Shatt al Arab waterway. A 1975 treaty, the Algiers Accord, represented an effort by the United Nations to mediate the final resolution of the boundary between the two countries, which largely divided the waterway down the middle while stipulating that Iran's support for Kurdish separatists in Iraq would cease.
In the meantime, Saddam Hussein continued his inexorable rise to power in Iraq, culminating in his accession to the presidency in 1979. Hussein, inspired far more by notions of pan-Arab nationalism than by Islam, was now "free" to pursue his territorial ambitions. Taking advantage of the political instability inside Iran following that country's revolution, he launched the invasion that started an bloody eight-year war.
The desire for power was one of the reasons the war was fought. Both the Ayatollah and Saddam Hussein coveted the idea of controlling the other. This led to the hostility that precipitated the war. The Ayatollah had just completed his Islamic Revolution in Iran, complemented with the holding of American Hostages in the US Embassy in Tehran. The prevailing belief was that the Ayatollah's conviction of bringing about a "purer" form of Islam was not something in the abstract. It was real. Being able to defeat his neighbor in Iraq was a part of this.
For Hussein, opportunity to control another nation presented itself when Iran was embroiled with its challenges in the Embassy crisis. Hussein understood that such an action would alienate Iran from "The West," thereby making it susceptible to attack. He was right, as Iraq enjoyed much from Western nations in supporting his fight against Iran. Arms, planes, resources, and military intelligence from the West poured into Iraq to help Hussein with his goal of controlling Iran. In the desire to control "the other" and coveting the opportunity to gain more power in the region, one of the deadliest wars since World War II was fought.