"Before the spies lay down for the night, she went up on the roof and said to them, 'I know that the Lord has given you this land and that a great fear of you has fallen on us, so that all who live in this country are melting in fear because of you." NIV translation
Now, we get to see why Rahab would risk her own life for the Israelite spies. We see that the people have heard that the Israelites are God's people and that He has already given them the land.
"'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 Sihon and Og, the two kings of the Amorites east of the Jordan, whom you completely destroyed. When we heard of it, our hearts melted in fear and everyone's courage failed because of you, for the Lord your God is God in heaven above and on the earth below.'" NIV translation
We see that she had simply acted out of fear because she feared the Lord more than she feared the king of Jericho. That, my friends, is the key to salvation for us as well. We must fear life and death without Christ more than we fear the persecution that comes with the faith.
"'Now then, please swear to me by the Lord that you will show kindness to my family, because I have shown kindness to you. Give me a sure sign that you will spare the lives of my father and mother, my brothers and sisters, and all who belong to them - and that you will save us from death.'" NIV translation
Rahab pleads for her family as well as herself. This is a picture of how we are to pray for those that do not fear (worship) the Lord.
"'Our lives for your lives!' the men assured her. 'If you do not tell what we are doing, we will treat you kindly and faithfully when the Lord gives us the land.'" NIV translation
So, it was agreed that her family would be spared in exchange for her cooperation. Rahab had believed that God had given Israel the land and she cooperated with them to save the lives of her family. This is a picture of the way that we come to salvation in that we simply must believe that God sent His Son (Jesus Christ) to pay for our sins.