The Iran-Iraq war was a war had been building for a long time. It was not so much because of problems between the people of these countries but more because of the personalities and belief systems of the people who rose to power there. The leader of Iran, Ayatollah Khomeini, had a clerical background and was very adamant that the world embrace the Muslim religion. He called for a Muslim uprising in all countries, including Iran. This, of course, did not happen because most of the people were not of the mind that the old ways were they way things should be now.
Although a cleric by training, Khomeini was not above warfare. He had a grudge against the former Shah of Iraq, who had exiled him from Iran until 1979. When the Shah came to the US for cancer treatment, Khomeini stormed the American embassy in Iran, taking hostages and demanding the return of the Shah for prosecution of crimes against Khomeini. This did not happen and Khomeini was forced to give up the fight. In Iraq, Saddam Hussein came into power and was ruthless in his quest to make Iraq a solid country.
He had watched as the Iraq people fought among themselves and overthrew different leaders. He was without mercy to those who threatened his power and had no problem disposing of anyone who stood in his way. These were not limited to political figures, but included small rebel groups and even entire villages that were rumored to oppose him. He decided that to make his country (and himself) stronger, he would invade Iran. He based this on the information that Iran was in a weakened military state and had internal turmoil that would lead to it being unprepared for invasion.
He wanted to gain control of the waterway that was the only port from Iraq to the Persian gulf. He also wanted to gain control of three small islands of the coast and annex another part of Iran, Khuzestan, as part of Iraq territory. In Sept 1980, Suddam attacked Iran and was surprised when the Iranians did not lay down their weapons and surrender to him. They chose, instead to fight back and try to rally together to fight off the forces of the invasion. This war went on for years, most of it being fought in Iraq.
Chemical warfare was used, both on troops and civilians. This went on for 8 long years and had a body count of millions on all sides. Khomeini and Saddam were eventually caught and executed. The war was ended but left the countries in chaos and misery. The United States and other countries have stepped in to help form a new government but progress is slow and there are still some who believe that the war should continue, these are small pockets of rebels and are not a serious threat to the new government.