Why is international law effective ?
First of all, we must note that international law is not always effective. Countries may choose to ignore international law and do whatever they want. This happens more often than we would like.
But this shows us why international law is sometimes effective. When it is effective it is effective because it is useful for all or most nations. Because we have international law, countries do not have to come into conflict with one another as often as they would have to if there were no international law. Instead of having to negotiate over every little issue that arises between countries, we can instead rely on international law to adjudicate these issues.
This is helpful for many countries. It helps them to be able to reduce the amount of conflict they face. Therefore, they are willing to cooperate with and obey international law most of the time.
The answer then, is that international law is effective (when it is) because it is useful to many countries and they therefore choose to obey it.