Capital punishment was once regarded, almost universally, as necessary, even just.  At least in theory.  Even "just punishments" can be applied unjustly, and minorities are a frequent target for unjust application.  And a "just punishment" which is unjustly inflicted in practice negates the intrinsic justice of the punishment!  Which is why state after state, country abolish the death penalty.