“I did not know where they came from.” Rahab lied to the leaders of Jericho, but to those leaders, what Rahab the prostitute said was a plausible statement. Jericho was on both a major north-south trade route and a major east-west route, so it is likely that lots of men came through, and Rahab would not know a lot about many of them, especially if they were not fluent in the local language.
This verse and others like it (cp. Exod. 1:15-20) reveal an ethical standard for what is a “lie,” or at least that there are times when lying is acceptable. God does not require us to give the accurate facts (“the truth”) to someone who will use them to harm us or God’s people. It is certainly good to give accurate facts when we can. Furthermore, this concept can and does get abused because there are times when people’s intentions are not clear, the circumstances are not easily discerned, or people just lie to protect themselves when they ought to tell the truth and deal honestly with the situation they are in. However, there are clear cases, such as here, where a “lie” is the will of God.
[For more on lying as a means of self-defense and more on civil disobedience see commentary on Exod. 1:19.]