Rahab (Hebrew: רָחָב) was wife of Salmon and the mother of Boaz.
Protecting the Israelites
After Moses' death, God appointed Joshua as Moses' successor and commanded Joshua to lead the Israelites across the Jordan River and into the Promised Land. God promised to aid Joshua on his mission to secure a homeland for the Israelites and asked Joshua to faithful, strong, and be courageous.
Rahab lived in Jericho as a prostitute. Her house was built into the wall of the city, and the city resided on land God promised to the Israelites. Joshua sent two scouts into Jericho, and they stayed in Rahab's house.
The King of Jericho learned that Israelite scouts had entered the city and had gone into Rahab's house. The King demanded that Rahab turn the scouts over to him, but Rahab decided to hide and protect them instead. Rahab hide the scouts beneath flax stalks on her roof and told the King's men that the two men had left and urged the King's men to pursue them. The King's men believed her and followed the red herring, out of the city.
Rahab then told the Israelite scouts that she was aware of God's promise to give the Israelites the land and of the miracles God performed in order to help the Israelite and informed them that the people of Jericho were afraid of what the Israelites and their God were capable of. She believed in God and asked for her and her family to be spared.
I know that the Lord has given you the land, and that the terror and dread of you has fallen on us, and that all the inhabitants of the land have melted [in despair] because of you. For we have heard how the Lord dried up the water of the Red Sea for you when you came out of Egypt, and what you did to the two kings of the Amorites who were beyond the Jordan [on the east], to Sihon and Og, whom you utterly destroyed. When we heard it, our hearts melted [in despair], and a [fighting] spirit no longer remained in any man because of you; for the Lord your God, He is God in heaven above and on earth beneath. And now, please swear [an oath] to me by the Lord, since I have shown you kindness, that you also will show kindness to my father’s household (family), and give me a pledge of truth and faithfulness, and spare my father and my mother and my brothers and my sisters, along with everyone who belongs to them, and let us all live.— Joshua 2:9–2:13 (AMP)
The scouts agreed, on the condition that Rahab keeps their presence and mission secret. Since her house was built into Jericho's wall, she was able to lower a rope that allowed the scouts to escape the city. Rahab provided the scouts with advise on how to evade the King's men.
The scouts then told Rahab that the safety of her and her family would be secure if she ties a scarlet cord from her window and she and her family remain in her house. Read agreed to this arrangement.
The scouts made their way back to Joshua safely using Rahab's advise, and they informed Joshua about how fearful the people of Jericho were of the Israelites and their God.
The taking of Jericho
Joshua and the Israelites crossed the Jordan with God's help, using the Ark of the Covenant. They gathered stones from the river's bottom and built a memorial as proof and a reminder of God's miracle. News of God's aid to the Israelites struck fear into the local Canaanite and Amorite rulers.
The Israelite army reached Jericho, and God instructed Joshua on how to archive victory. Per God's command, they marched around the city with seven priests marching in front of the Ark, blowing trumpets. They marched around the city once per day for six days, then seven times around the city on the seventh and final day. On the final time around the city, Joshua ordered his men to shout and to not fill their own pockets once the walls come down, since everything within, except for Rahab's house and everything and everyone inside it, was to be delivered to God.
The men shouted, and the walls of the city came down. The Israelites rushed in and defeated and slaughtered their enemies. Only Rahab and her family remained. Joshua ordered the two scouts to escort Rahab and her family out of the city. They then burned the city to the ground and devoted its gold, silver, and other metals to God's treasury.
Rahab then lived among the Israelites. She married Salmon and gave birth to Boaz.