Afghanistan was where Bin Ladin and his minions were entrenched and it was controlled by the Taliban which openly supported Bin Ladin.
Iraq, OTOH, was controlled by an aging, secularist, evil, despot who, most experts agree, pretty much limited his actions outside Iraq to sending a few bucks to PLO terrorists.
In anticipation of your next question .... the difference between Iraq and Saudi Arabia is that S.A. is the home of the Wahhabis and the financial sponsor of nearly all the worldwide terror.
Or, maybe your question would be ... what is the difference between Iraq and Pakistan? The answer to that is that Bin Ladin and Al Queda were/are residing in Pakistan but the U.S. decided to pursue imaginary WMD's in Iraq instead!