Why would God do that? The One whose name is Redeemer wanted to tell something to us. That wasn’t the end of the story.
Next time we meet this woman in genealogy of Jesus Christ. And her title there was changed on mother.
I picture the drama that was happening in Jericho. The city was doomed. God himself came as a leader of the army of God to destroy the evil city. But her house ( in the wall) was left untouched. God knew the address of this woman. And Israelites not only saved her life and the lives of those who belonged to her, they took her with them. In spite of the law and what it says about prostitutes and future of their children, she was given a grace and mercy. She got married. She became one of them. And as result she raised great son by the name of Boaz who showed mercy to another well know woman Ruth, and who became great grandfather of the King David and Jesus himself.