Kisra, A Persian King, was once asked, “How did you learn justice?”
He replied, “Because I know for sure that every man will he judged according to his deeds.”
He was then asked: “How do you know that?”
He replied: “One day when I was on my way in the forest, I saw a gazelle. I sent my dog after it and it caught the gazelle by the leg. But the dog did not catch the gazelle in the usual way, for it bit and broke the gazelle's leg.
Not long after, the dog was in front of a horse, that kicked it in the leg and the dog's leg was broken.
Soon after, the horse's leg slipped into a hole and it broke.
Therefore, I realised that every person's award depends upon his deeds. When he does a good deed, he will be rewarded for it, and if he does an evil deed, he will be punished. Hence, I always do good deeds.”
God does no wrong or evil. Anybody who commits wrong or injustice does so either because he does not know that it is wrong (but God knows everything or because he needs something which cannot be obtained without wrong doing (but God has no need) or because he has been compelled by somebody else to commit that wrong (but God is All-Powerful and nobody can compel Him to do anything. So it makes sense that it is impossible for God to do any injustice or wrong.
So logically we say that God is Adil, meaning that he is just. He is neither cruel nor does he do anything that lacks in wisdom. Whatever he does be it endowing life or giving sustenance or depriving us of anything, it has inherent benefit in it; though the Benefit may not be apparent to us.
For example, when a doctor treats an illness, we know the patient benefits from the treatment, though we do not know how the treatment brings about the benefit. Thus, when we see God endowing one with riches, while leaving another in poverty, or granting one person greatness while denying it to the other, or bestowing health on one while the other is stricken with disease, we have to accept that these actions are based on rationalism even though we may not be able to understand the wisdom behind them.
“And Allah is not in the least unjust to His servants” - Qur'an: (Chapter 8 Verse 51)