Why did the U.S. support Saddam Hussein and lraq in the war against Iran in the 1980s?
At that time the main threat as far as the US was concerned came from the Shia government in Iran led by Ayatollah Khomeini.
The Americans saw Iran as a threat because it had overthrown the Western backed Shah. Also the rise of Shia power in the Middle East was seen as a threat by Sunni governments such as the Gulf States and Saudi Arabia who were powerful allies of the Americans.
At any given point in time US foreign policy as with all countries is governed by self interest. In the case of the Middle East that is access to strategic military bases, and a guaranteed supply of oil and gas. Saddam Hussein was bolstered by the West throughout the 1980's because his aggression to Iran resulting in the Iran - Iraq war was seen as useful in acting as a check on the rise of Shia power.
The fact that Hussein was a brutal dictator was not a problem for the West. In fact it was an advantage in stemming perceived threats to Western interests. When he gassed Kurds in the north-west of Iraq and massacred Marsh Arabs in the south the West did nothing.
When Hussein attacked Kuwait he became a liability and so the first Gulf War was fought. Even then the Americans encouraged the Shia in southern Iraq to rise up against him. However when they did so the Saudis made it clear to the USA they would not tolerate further support. As a consequence after being encouraged to rebel the West stood back and let Hussein massacre at least 100,000 Shia Iraqis.
Such is the way of realpolitik.