In Joshua Chapter 2 we see the salvation of Rahab when the spies are sent to the city of Jericho. The Chapter takes place during the three days when Joshua has commanded the nation to wait on the banks of the Jordan (Joshua 1:11). God has a special purpose for these three days.
Some Bible commentators, including Mathew Henry, have tried to say that Rahab was simply an "innkeeper," but the language is clear enough. The Bible is clear, she was a harlot. The fact that a harlot in a pagan land can exercise faith and find salvation is the beauty of this Chapter. The gospel is for sinners who know they are sinners.
Rahab put her own life on the line for these men because of faith. Rahab says “I know that the LORD has given you the land.” God had a plan in bringing Rahab and the spies together. In spite of living in this pagan land, Rahab says “He is God in heaven above and on earth beneath.” She may not have a strong or perfect faith, but her faith is genuine. Hebrews 11:31 says “By faith the harlot Rahab perished not with them that believed not, when she had received the spies with peace.” Rahab was not saved by her works, but by her faith; she knew who God was, she knew who she was, and she trusted God for salvation.
The Scarlet Cord. In spite of the fact that she desired to be saved, had faith, and had obtained the promise of the spies, she still needed to trust in a blood red cord hanging from her window to be saved. This scarlet cord as a symbol of the blood of Jesus. Rahab put the cord in the window as soon as the spies told her to do so. She exercised immediate faith in being identified by this scarlet cord, just as we need to place immediate faith in the blood of Jesus.
Ultimately, the information gathered by the spies did nothing to impact the battle of Jericho. God was going to fight this battle using a strategy that no reasonable man would follow in his own strength. However, putting faith in the Lord and following his plan gives the victory. The true purpose of the mission, while not known to man, was to save Rahab, probably the last person that these men would have picked to save, but one who God places in the family tree of our Lord and Savior, Jesus Christ. God can save someone like Rahab, and He works in amazing ways to bring about that salvation.