Justice implies two things. Its first purpose is to punish the evil-doer and protect the righteous and good. Its second purpose that derives from the first is to maintain the balance of creation so that the general consciousness of humanity does not sink below in such a dangerous way that a wholesale or mass destruction remains the only way left to restore the lost balance.
When we think of this in human terms we can only think of physical and material rewards and punishments since we value these alone and our vision is limited only to these things. But the Divine Vision sees much more. It lets a man grow rich through foul means and exploitation of the poor. But a price is extracted in this process. He becomes more and more entrenched in darkness and falsehood thereby cutting himself more and more from the natural joy of life. Then to get back that lost joy he tries lot of artificial means such as parties, drugs, lustful activities and grabbing of political power. The more he does so he is more and more cut off from the Divine Presence within and the joy and peace and happiness that comes from It. Now unless there is a course correction due to some shock or Divine Grace he finds himself more and more surrounded by flatterers and loses the joy that friends and family can give. Finally he dies in a state of fear and anxiety and worry over losing all that he has unjustly amassed. Of course he dies with a lot of money in his wallet but a big hole in his heart, loveless though surrounded with selfish men who are after his wealth and position. As if this is not enough, since he misused the gifts of Nature given to him, he returns in a miserable birth deprived of all that he misused to resume his further journey under much more difficult conditions. I am not saying that it happens exactly like this but there is a truth in the idea that there is no greater punishment than to wander away from our divine core, to lose one’s natural joy, to live in a state of obscurity and inner darkness, cut off from all true light and peace and joy.
We are unable to see this larger picture because our eyes scan only the surfaces and can see life only in small sections of Time. Therefore we ignorantly believe that a king of a politician who has amassed wealth and power by unjust means is fortunate whereas the seeming ordinary not so rich person who lives with modest income, a life of piety and goodness is not so fortunate. But this is an error of the senses. Kansa, the king of Mathura suffered in his royal palace while the commoners of Vrindavan rejoiced dancing with Krishna. Duryodhana suffered with jealousy and ambition and anger and suicidal thoughts as the king of Hastinapur, the most powerful and influential Kingdom of those times. On the other hand, the Pandavas grew through the ordeals in the forest and have become an ideal for men to follow. Such are the strange ways of Divine justice, strange and mysterious to our superficial vision, but perfectly rational and legit to a deeper and comprehensive view of things.