It has replaced one threat to Iran with another. Whether one is greater than the other is yet to be determined.
Threats don't sign defense pacts with you.
Ever heard the saying "Keep your friends close, keep your enemies even closer"? Not saying that's the situation, as I don't know enough to make a real judgement, but signing a treaty or pact of some sort is a good way to diminish the level of threat another country poses. I'd say Iraq doesn't want to be threatened by Iran, and visa versa, so a defense pact would help ease tensions on both sides.