The two spies sent by Yehoshua to Jericho chose to spend the night there in the house of a prostitute named Rachav.
Understandably, this choice has scandalized generations of Biblical commentators. (Artscroll, for example, says Rachav was an "innkeeper" rather than a prostitute. Some older commentators translate "zonah" as "food merchant", which at least has a plausible etymology.) Why would the spies, who by all accounts were upstanding people who performed their job professionally, visit a prostitute in the middle of their mission?
One reason is that prostitutes, by the nature of their work, are required to be good at keeping secrets. Many of their customers would not be happy if news of their sexual escapades became well-known. Thus the spies could trust Rachav to keep their secret, more than they could have trusted a citizen chosen at random.
Another reason is that since the spies were probably nervous, suspicious-looking people, it was in their interest to behave like other such people and pretend just to be looking for sex. Thus their erratic behavior would be ascribed to a desire to avoid embarrassment, rather than a desire to avoid being revealed as spies.
A third possible reason is that prostitutes were probably lower-class and had less to lose by betraying their city for the enemy, Israel.