Romans 9:14-16 — What shall we say then? Is there unrighteousness with God? God forbid.
For He saith to Moses, I will have mercy on whom I will have mercy, and I will have compassion on whom I will have compassion.
So then it is not of him that willeth, nor of him that runneth, but of God that sheweth mercy.
The quote is to Moses (Exodus 33:19) when Moses interceded for Israel after the people made the golden calf.
Since the Jews rejected salvation, God offered it to the Gentiles. Jews might respond that this was unrighteous.
God's mercy and compassion are not determined apart from His character. The cause is not in human will or effort.
There are two sides to grace, and Romans deals with them both. On one side is represented Romans 10:12-13 — For there is no difference between the Jew and the Greek: for the same Lord over all is rich unto all that call upon Him. For whosoever shall call upon the name of the Lord shall be saved.
This is grace indeed; salvation full and free, offered to all who will simply "call upon the name of the Lord."
But there is another side to grace — a side against which many people rebel. It is the side that proclaims that salvation is wholly of God, entirely apart from man's will or his works. — The Epistle of Paul to the Romans, by Cornelius R. Stam, page 226