The last time oil tankers were being shot up in the Persian Gulf, back in the 1980s, it was Saddam Hussein's brutal tyranny in Iraq versus Ayatollah Khomeini's revolutionary Islamist regime in Iran, and people used to say, "It's a shame that both sides can't lose."
The United States backed Saddam because he was just another murderous thug, whereas the new regime in Tehran was an actual threat to American interests. It had overthrown Iran's American-backed puppet king and wanted to spread its Islamist ideology across the region.
So of course, Ronald Reagan's administration chose Saddam's side. It sent Iraq arms by clandestine means (because Congress wouldn't authorise it), and even provided targeting information for Iraqi poison gas attacks on Iran. The Americans chose the "lesser evil", but at least they knew it was evil.