Look up Kohlberg’s theory of moral development. Laws don’t exist for the sake of punishment but to regulate life while there is no conflict.
International law was established to create a basis for the relationship nations have after they are done fighting. Would you trust a neighbor to uphold their contracts in peacetime who committed unspeakable atrocities towards you? Or would you rather trust someone who followed an agreed upon moral guideline?