What shall we say then? Is there injustice on God's part? By no means!  For he says to Moses, “I will have mercy on whom I have mercy, and I will have compassion on whom I have compassion.” (ESV)
One of the greatest complaints against God is that he is unjust. This complaint is usually offered by those who live in rebellion to God's sovereign rule. They look at how he has mercy on some and not others and they assume he is being partial or unjust. Paul even assumed that some of his readers in his day would level that accusation. He is prepared to address the issue.
Paul offers a rhetorical question: "Is there injustice on God's part?" The answer is an emphatic "No!" Those who would complain about God's justice are thinking that the offer of mercy should be determined by man and his own efforts. The reality is that God is very much in control of who he is offering mercy to.
To the Jews who would insist that God's mercy should be based on man's works, particularly the keeping of the Law, Paul refers them back to the one who wrote down the Law, Moses. God told Moses (Exodus 33) that he will have mercy on whom he has mercy. The Jews were proud of their heritage. Paul brings them back to Moses to remind them of God's character.
It is significant that this account in Exodus 33 is when God displayed his glory to Moses. Moses asked God to reveal his glory. The Lord told Moses that he would not be allowed to see God face to face, but he would reveal himself. Moses was able to get a first hand glimpse at who God was. In this encounter God tells Moses that he will have mercy on whom he will have mercy.
God is not unjust. He has the right to offer mercy as he sovereignly chooses. He is not under any obligation to show mercy to anyone. The fact that he does so at all speaks of his glory and his kindness.