In an amoral world, sadism bootstraps morality. A propensity to take pleasure in the suffering of others, channeled to inflict punishment on those who have violated an emerging norm, provides the motive force to bring moral norms into existence by engendering fear of the pain of punishment in others.
Once established, formal enforcement of the most essential moral norms is handed over to an authority to prevent “the war of all against all” and in the best cases, apply the norm impartially.
But the sadistic impulse remains in the individual, creating a problem for a just society when it extends beyond mere schadenfreude and is misdirected in various forms of revenge, retribution, vengeance, and outright sadism, as well as giving rise to the false idea of retributive “justice”.