The story of the sainted Rahab is one of those very interesting stories from the OT, and one that tends to get glossed over way too much. Probably because we are uncomfortable with Rahab's occupation.
Which is a prostitute. Since we are Americans, and since we all carry the burden of our Puritan heritage around on our backs, we are inclined to explain her work as something else. Innkeeper is the one I hear most often. Another is that she was a sort of a madam, which is our female version of a pimp, and sounds -- for some reason -- more palatable to our ears.
But the Bible will have none of it: James 2.25 confirms what Joshua 2.1 infers: she was a prostitute. And in Joshua 2, the 2 Israelite spies lodge at her house.
Which begs the question: what were they doing there? One very logical answer -- that they were using the establishment for what it was designed for -- is one we don't usually touch. It wouldn't be that unusual, given that they were likely young men, but the more likely answer is that young men going into a prostitute's house wouldn't raise an eyebrow. It's a perfect cover for spies, and that's what they were there for. Jericho was not that large a city; Kathleen Kenyon has estimated a population of 3,000, which isn't that large, and 2 spies -- who might not have spoken the language -- would have been obvious to the inhabitants of the city. Staying there would be a logical choice.
(Lodging for travelers was tough in biblical times. Many places described as "inns" would have been rough housing, with thievery and physical danger as part of the landscape. We tend to think badly of the apocryphal innkeeper from Luke 2, and he's usually imagined as a hard-hearted person who would turn away a full-term pregnant woman. He's also become a stock figure in children's Christmas pageants. The reality is that his giving the Virgin and her husband a place in the animal cave might have been the kindest alternative, given that the inn -- more like a variety of a Caravanserai -- would likely have been dirty, loud, and dangerous for the mother and her newborn Son. The link above is a fascinating overview of the caravanserai in the middle east in current times).
More on Rahab later.