An excerpt from "Got Questions.org" entitled, "What Does God mean when He says, " I will have mercy on whom I will have mercy " (Exodus 33:19)?" states: "“I will have mercy on whom I will have mercy” means God’s freedom to demonstrate mercy is not limited by anything but His own divine choice. God does not show mercy because humans deserve it. The Lord’s favor cannot be earned by status, social class, or works of righteousness—otherwise, it would not be mercy." This article may be viewed at: What Does God mean when He says, "I will have mercy on whom I will have mercy"/gotquestions.org
Reference: Romans 9:15