Justice is the balancing of emotional energy.
Societies collapse because they try to make justice solely logical. They set up bureaucratic systems to standardize judgement and punishment with the promise of equality. But, over time, because of bias and outright corruption, the weight of justice, the balance of emotional responsibility, gets pushed more and more onto the poor. The rich pay fines that are insignificant to them as punishment for major crimes, and the poor pay with their lives for minor infractions. Eventually, and without fail, the scale breaks.
There is no way to make justice completely logical. Justice is the balancing of emotional energy.
The future of human society, if humans will ever grow past where we are now, is impossible for us to imagine… logically.