Joshua was feeling pretty good about himself. He was a proud and violent man. He thought a lot of himself. Joshua in this story is an ideologue. An ideologue devoted to a false ideology.
In Numbers 27:15-21 Moses asks God for a man,
17Which may go out before them, and which may go in before them, and which may lead them out, and which may bring them in; that the congregation of the LORD be not as sheep which have no shepherd.And God says,
...at his word shall they go out, and at his word they shall come in, both he, and all the children of Israel with him, even all the congregation.James Alison says,
A passage I particularly like is John 10, in which Jesus proclaims that he is the door of the sheep. First he tells his listeners that a good shepherd is one who watches over his sheep and leads them to and from pasture; they hear his voice and follow him.A good shepherd will watch over his sheep. Mr. Alison continues,
Suddenly Jesus' image acquires a significant new vibrancy: the pasture which he leads his sheep to and from, going in before them and coming out again, is not the usual pasture, but a "pasture" with a one-way entrance: the gate to the abbattoir. Other sacrificers take the sheep without entering through the gate; robbers and thieves, they are not prepared to carry out the sacrificial lynching themselves, but pick off sheep for sacrifice from a safe distance. When they hear the wrath of the lynch mob coming close, they run away. But the Good Shepherd is happy to go through the gate, occupying the space of the sacrificial lynching for his sheep, who thereafter know that it is not a trap; they will always be able to hear his voice and follow him in and out.Joshua in his pride and haughtiness believes that Ai will be easy for him to conquer. The reports from the spies say the city is small. With apparent prompting from the spies Joshua decides only a small number of people need toil at Ai, while the rest can stay back in the Israelite camp and continue the celebration of the victory at Jericho. Joshua declares that the good times and partying will continue, only the lowly need to toil and risk their lives at Ai. So Joshua sends the lowly, the people who don't quite fit in, to venture through the sacrificial machinery at Ai. Joshua the shepherd of Israelites declares that the people he is sending out the toil through the sacrificial machinery at Ai are not worth his attention. He doesn't care about them, he is too good to go out with them. He's still enjoying the victory at Jericho with his friends. Can't interrupt his partying with Rahab and all the gold and silver he's collected to go out and risk his life with the unpleasant lower classes.
The Israelites were defeated at Ai. They fled and thirty-six men were killed. "The hearts of the people melted and turned to water." They showed as much interest in taking Ai as Joshua did. If Joshua was going to sit back and party, why should they risk life and limb to take Ai. Joshua is just going to take all the gold anyway.
After the defeat Joshua gets all melodramatic like a typical scapegoater. The defeat couldn't possibly be his fault. He's a slick politician, victories belong to him, defeats belong to the people and the scapegoats. The manifest destiny ideologue asks God/tells the people resentfully "Why have you brought this people across the Jordan at all, to hand us over to the Amorites so as to destroy us?" He can't admit that the defeat at Ai was a leadership failure. He questions the people's courage and terrorizes them with the idea that the Amorites will come and slaughter them and their children.
People are angry at Joshua. They resent Joshua. Their relatives have been killed because of Joshua's lack of leadership. There may be actual violence occurring between the Joshua and anti-Joshua partisans. The bonds of the Israelite community are dissolving. The covenant held all things together. Joshua was man responsible for holding the people together. To lead them all out and to lead them all back. Joshua has broken the covenant, people have been killed. The whole community is on the verge of self-destruction. They don't love Yahweh, the people need a scapegoat to renew the covenant. Joshua is a substitute for the entire community. It's either his death or the death of the community. Joshua realizes this. The community at this point is under the wrath of god. Joshua is refusing to provide himself as a scapegoat.
Joshua realizes that all you need is one person to be a substitute for the whole community. To absorb the wrath that is beginning to boil in the people. So in a highly ritualized drama, Joshua parades the entire community before him, by allowing the people to receive a "not guilty" from him he absorbs their sin and takes it away. Family after family parades before Joshua, he is absorbing their sin, freeing them from the consequences of their own wrath. It doesn't matter if Achan actually had loot or not, he is a scapegoat. Then finally Achan is chosen. The people have never liked Achan, some say he was a criminal, or just didn't like his unpleasant personality. After the parade of families Joshua now has absorbed and possesses in his person all the sins of the Israelites. The second Joshua, Jesus, at this point refused to lay all sin on someone elses head. This Joshua finds a surrogate victim in Achan. Joshua is a substitute for the entire community, Achan is a substitute for Joshua. Joshua is the high priest, Achan is the lamb. Joshua places the sins of the community onto the head of Achan. Achan whether he likes it or not has become the servant of the lord. The bonds of the community are now his responsibility. He will literally unite and draw all the Israelites to him. He is the scapegoat. He takes their sins away. They can focus their hatred on Achan instead of each other. They will all become friends again. Joshua now has provided a scapegoat for the community. All the responsibility for defeat has been placed on Achan, the rest of the people have received a big "not guilty".
The Israelites go on to take Ai with a much larger force than the first time. This time Joshua made sure to lead the way.