The standard conservative/literal reading of Joshua 7 is that Achan caused the defeat at Ai and that it was right and moral for Achan to be brutally killed with stones and fire.
Of course the 21st century mind sees no connection between Achan allegedly taking some spoils from Jericho and the defeat at Ai.
Achan is a precursor or an anticipation of the Christ figure. He is a man innocent of the crime which he is accused. He did not cause the defeat at Ai. I gotta tell you I don't trust any stories that come from lynch mobs. This story is being told by a lynch mob. Achan's confession may be like the confessions in Soviet show trials. This is a story about the formation of group unanimity and renewing the bonds of the group with a blood sacrifice.
Achan was murdered. Achan was viciously killed by a lynch mob. Regardless of how the so-called literalists want us to understand this text, God was on the side of Achan and not the lynch mob.
Joshua was supposed to be a "Shepherd". He was not a good "Shepherd. Jesus was a good shepherd, he didn't lose any of His sheep. In this story Joshua makes a human sacrifice of one of his sheep. Achan is sacrificed for group unity. Achan is sacrificed in Joshua's place. Jesus is the new Joshua. Jesus doesn't kill any of his sheep to save Himself.
After the defeat at Ai the group was on the verge of disintegration. Joshua knew that because as the leader he would sooner or later himself be sacrificed to restore group unity. Joshua wasn't a good shepherd. He knew that someone had to die, and it wasn't going to be him. He needed a scapegoat. Achan had all the signs of a scapegoat. Achan was not a man well-liked by the people. A sinner and hardened criminal. He didn't have friends. If Joshua pointed the finger at Achan, no one would come to his defense. It may have been a long time that people had been wishing for Achan's death. Joshua knew it was either him or Achan.
Numbers 27:15-21 would lead one to believe that the cause of the defeat at Ai was that Joshua did not lead his people into battle. In this section God commands Joshua to march at the head of the army. Now I think you could make a pretty good case that Joshua was in fact responsible for the defeat at Ai. Joshua was supposed to lead the army into battle, to "go out before them".
From the Legends of the Jews:
"He, however shall be a man 'which may go out before them,' who, unlike the kings of the heathens, that send their legions to war but themselves remain at home, shall himself lead Israel to war. But he shall also be at man 'which may come in before them;' may it be granted him to see the number of those returning from war no less than that of those going into war. "O Lord of the world!" continued Moses, "Thou hast led Israel out of Egypt, not to punish them for their sins, but to forgive them, and thou has not led them out of Egypt that they may be without leaders, but that they may indeed have leaders..."
Joshua is not the good shepherd, not only has he lost sheep, but he has intentionally sacrificed one. Did he stay at home out of pride and hubris?
Achan, if we believe what the text says, has realized that he is the lamb that will be sacrificed for group unity. He doesn't point the finger at others, he takes Joshua's sins and the community's sins upon himself and the community is cleansed and renewed by the death of Achan. Achan removes the sin of the community. The community has united around the dead and brutalized body of Achan. This story has many similarities with Isaiah 53. The Achan story is a real-life atonement event. Stories like Achan's are what underlie the Atonement ritual. Stories similar to this underlie the Gospels and what Jesus is doing. Jesus is uniting humanity around His broken body. He allows His body to be broken so that others won't have to be.