If you read the chapter before: Joshua 5:15 Then the Commander of the Lords army said to Joshua,"Take your sandal of your foot, for the place where you stand is holy." And Joshua did so.
This was on the plains of Jericho. So Joshua who was leading them to the land that God promised, had to keep it clean as it was holy ground. The city was not holy and had accursed things, with which later, they took with them after its destruction. The city was not to be rebuilt.
Joshua 6:18 " And you, by all means abstain from the accursed things, lest you become accursed when you take of the accursed things, and make the camp of Israel a curse, and trouble it.
What I find interesting is this from Origen's homily on Joshua.
IV. Joshua could not be a leader unless Moses dies (Jos. 1:2); thus the soul cannot receive Jesus Christ as her Groom unless her first husband (Mosesí Law) dies, or she would be considered as an adulterous ( Rom. 7:1-4).
There was a necessity that Moses dies, so that the believers would not be accused of adultery.
If we do not understand how Moses dies we canít understand how Christ reigns.
The ones who were the harlots and who were saved by both Jesus and Joshua, were Rahab and Mary Magdeline. Both women could be accused of adultery, but Rahab hid the messengers and Mary was with the desciples.