Things are not so clear as presented in the opinions above.
A space rock threatening (part of?) Earth might be anything from a "planet killer" several miles wide to a city devastator, to an ice melter in Greenland, or a tsunami creator in one of the oceans. And, who gets hit if nobody does anything might not be real clear at the point in time that the decision needs to be made whether to do something and, if so, what.
And, then there is the predictability of the result of whatever attempt is made to deflect the threat. Will a planet killer completely miss, or turn into several city killers, tsunami creators, and ice melters if we hit it with an explosive, or even a large inert impactor? Will some technique for deflecting the object without breaking it up succeed in creating a complete miss, or maybe not be as effective as predicted and just move the point of impact?
There is going to be a lot involved in making a decision about who should do what. The more we know about the threatening objects and the farther the development of the defense mechanisms has been pushed by the time we have that decision to make, the better that decision can be.
As for a "free ride" by the technologically incapable nations, that's just the way life works. Not being able to protect yourself because you might end up protecting somebody else, too, or even instead, is not a logical reason to remain defenseless. Most of the money needs to be spent well before the threatening object has been detected.
And, the decisions of the capable countries to launch is not going to be blocked by some international organization haggling until actual doomsday. The nations with the ability need to coordinate their efforts - and now would be a good time to start doing that.