The US couldn't defeat Afghanistan and Afghanistan is a significantly poorer and less populous country. The US though can still weaken or ruin Iran for years to come. Iraq is a shell of its former self more than a decade after the US invasion.
I want to be optimistic but the US is dangerous and no one will hold it accountable if it decided to use nuclear weapons.