Iran and Libya were both active terrorist contributors, Iraq was judged less a threat b/c they weren't funding people like Carlos who had ties with Russia.
At the time Khomeini (sp) was arguably one of the most dangerous men in the mind of many foreign affair planners.
Its very silly to forget about all the details when revising history, especially in the complicated Cold war days. Motives are forgotten and hindsight 20/20 is always enforced.
Hell we funded and trained Al Qaeda. At the time, they served our purposes, since we had a common enemy, indeed rational people thought it was a good thing.
It would be impossible to say whether that was ultimately a good thing, or a bad thing, since history isn't made with ifs.