Rahab helps two spies that Joshua had sent into Jericho as the Israelites prepared to begin the conquest of Canaan. In light of her help in their mission-in fact, she saved their lives as well as their mission-Rahab requests that her and her family be shown mercy. Mercy is sympathy or compassion that motivates into helpful action. Rahab is looking for some sympathy and some saving.
Since chapter one of Joshua makes it clear that the conquest of the Promised Land was ultimately God's battle, her petition is ultimately directed to Yahweh; will God be merciful to Rahab and not destroy her.
Not killing Rahab would be merciful. But God, as is His practice with His enemies, goes beyond being merciful to Rahab and is utterly gracious to her. God's grace is His sovereign and unmerited favour. God, through the Israelites, goes beyond just not killing Rahab and her family; he adopts them into his own covenant people. In the sixth chapter of Joshua we learn that Rahab and her kin are incorporated into God's family. Stunning!
This is how God has acted towards us. He has shown us mercy which motivated his gracious action in saving us from destruction and adopting us into His family. And He did this in the work of Jesus Christ.
Praise the merciful and gracious Sovereign God!