The reason why we have rules of war is for the same reason that we have laws. The objective of any person is to live as long and as comfortably as possible without incurring damage. So why do we have laws? Simple -- a society without laws is unstable. As a matter of fact, in such a society, even if you're the top dog in your community, you'll still suffer a lot more than if you lived in a peaceful society with laws. In other words, laws do allow you to live longer and more comfortably. The same goes for war. I don't think I need to re-explain the analogy for it.

But it would seem that if anyone broke this 'international code of war', it would be very advantageous for them, no? Of course, just as it would be advantageous in the short term for a person to break the law and control others in her/his vicinity. But, as I said earlier, the fact that one person is breaking the rules puts everyone else at a disadvantage -- so they'll naturally start breaking the rules, too. And this will lead to an unstable society in which it's quite likely that the one who broke the rules first will lose out. So the reason why we have rules of war is simply this: it may seem stupid, but it's the smart thing to do in the long run.