I wonder if there is an older record of the concept of social justice than the story of Naboth’s Vineyard from 1 Kings 21. The conclusion, in 1 Kings 21:17-19
Then the word of the Lord came to Elijah the Tishbite:
“Go down to meet Ahab king of Israel, who rules in Samaria. He is now in Naboth’s vineyard, where he has gone to take possession of it.
Say to him, ‘This is what the Lord says: Have you not murdered a man and seized his property?’ Then say to him, ‘This is what the Lord says: In the place where dogs licked up Naboth’s blood, dogs will lick up your blood—yes, yours!’”
frames the punishment for the injustice Ahab, almost 3,000 years ago, as a judgement from God. This is of course to say that even a king cannot act unjust and is believed to have been written more than 2,500 years ago.
See also John Milton’s attempt in 1649 to explain essentially the same thing, to justify the execution of King Charles I, in “The Tenure of Kings and Magistrates“.