My friend, I study this stuff and understand what happened.
I am not asserting that Iraq won the war but it did give Iran one hell of a fight which lasted 7 - 8 years straight. Now, both countries had their share of flaws. Iraqi military wasn't large enough, and well-equipped enough, to invade Iran back in the 1980 but Saddam Hussein foolishly gave this order; what happened is that Iraqi military conquered certain parts of Iran but failed to make deeper inroads and take over Tehran due to Iranian resistance. Now Iranian resistance at this stage was nothing significant due to the reasons you pointed out but failure of Iraqi military forces to advance further provided sufficient breathing space to Iranian regime to galvanize Iranian public to fight for the country and commit lot of manpower to this cause. IRGC came into being and Iranian military managed to regroup and both factions took the initiative to oust Iraqi military forces from Iranian territory in tandem (cooperation). When this happened, Saddam Hussein offered terms for lasting peace to Ayatollah Khomeini but the latter rejected it. In fact, Iranian military forces invaded certain parts of Iraq [an accomplished worth talking about] but Iraq began to receive lot of foreign aid from this point on and Iraqi people began to mobilize for war on a much bigger scale than ever before, and Iranian military capability diminished by 1988 whereas Iraq had a powerful military at its disposal at this stage. It was at this point that Ayatollah Khomeini considered peaceful resolution to the war. One thing is that since Iraq was short on naval front and Iranian Navy had monopoly in this domain, Iranian Navy took the bait of USN and drew it into a shooting contest (Operation Praying Mantis) in 1988 which resulted in significant losses on Iranian side and Ayatollah Khomeini lost this leverage in deciding terms for peace consequently.
Most unfortunate is the fact that a huge number of Muslims lost their lives in this war, and it qualify as one of the darkest chapters of Islamic history. Allah Almighty punished Iraq for its transgressions but Iran haven't learned a lesson either (need to give up its interventionist designs). So my friend, understand that much can go wrong for Iran in the most recent conflict. This isn't to say that Iran is weak but US is too powerful an adversary to exchange blows with and not suffering tremendously. Ballistic missiles will not accomplish much - I tell you.
You are derailing. You said "Iraqi people had similar boasts that US will utterly fail in Iraq but they were proven wrong. This same Iraq gave Iran one hell of a fight earlier - do not forget this" I responded to your claim by providing the facts that Iran had essentially a non existent military, was in chaos, embargoed, fought off an Iraq supported by almost the entire world. But still didn't lose the war. You are basically saying the Iraq that got wrecked by US gave Iran a hell of a fight for 8 years without considering any of the facts I mentioned. You cannot compare the Iran of 1980 to the Iran of today. And you cannot compare Saddam vs US to Iran vs US.
But anyways. Say US declares war on Iran. What is the objective of this war?