The Babylonian Theodicy, written around 1000 BCE, is a poem and philosophical dialog between two friends and equals, one who was abandoned as a child by parents who then died, and the other who says suffering and death is common to all.
The first asks how we can get out of suffering, and the second says that a good and just life is rewarded.
The first says that animals and humanity commit crimes that go unpunished, and the second says that no crime truly goes unpunished.
The first says that religion and cultivating his relationships with the gods seems to do nothing, and the second warns the first that it is unwise to question the greater wisdom of the gods and cosmos.
The first says that the wealthy commit injustice against the poor and prosper, with the courts and public opinion siding with the wealthy against the poor, and the second says that this is true, but part of how the gods made humanity imperfect, with greater strength to those who must fight for justice.
In the end, both agree that we should be just to please the gods, but also that the gods created injustice as part of the plan.