So the Israelites have just destroyed Jericho. Before they attacked, Joshua specifically told them to not take anything from inside the city; they were to burn it all and leave it there. But some guy, Achan, didn't listen. He took something (a "devoted thing"... and idol or some holy symbol, maybe?), and now they must all suffer for it. Obviously.
Joshua sends a couple of guys out to spy on the next target, Ai (which is an awesome name for a city). These spies are better than the last; they return with no problems. They report that there aren't many people there, so they don't even have to use their entire army. Just send a few thousand people. So that's what they do...little do they know that God is pissed that Achan took something from Jericho, so he let a bunch of them die in the attack. Not only that, but they fail to conquer the city and are chased off.
Joshua says, "What the hell, God? I thought you were going to be helping us out!" God says, "Nope, I'm pissed because somebody took something from Jericho. I know I could have told you this before all those people died, but what fun would that be? Anyway, if you want my help you'll have to find them and destroy them." God tells Joshua to get the people ready, and tomorrow Joshua should present them family by family before him. If they are found with the stolen items, they will be burned to death. I do find it amusing that all-knowing God has to search people in this limited fashion, one family at a time.
So the next day, Achan's turn comes up, and he stupidly confesses. They take him and all his children to some valley and stone them all to death. Because that's fair; the children were totally to blame. Also, I thought God was going to burn them to death...guess not.
As far as I can see, this is just a story about superstitious people and stupid brutality. Superstitious people loose battle, find scapegoat, murder scapegoat. Fantastic.
Then God says, "Thanks for murdering that guy and his children! Now I'm not mad anymore!" He tells Joshua to send the entire army to Ai and conquer it. He also gives them permission to loot it. Weird.
So, this time 30,000 men go to Ai. 25,000 men led by Joshua run away and get all the men of Ai to chase them. Meanwhile, while everyone from Ai who know how to fight are away, the 5,000 other Israelites run in to Ai and slaughter the women and children. Then Joshua and his men stop running, fight the men from Ai, and kill them all. A successful mission!
It's amazing what 30,000 men and a tricky ambush can do, compared with 3,000 men doing a straightforward attack. Wait, I mean, it's all because God helped them out this time!!!! Yeah.
Anyway, after they kill everyone, they loot the city and burn it to the ground.
Then they go to Mount Ebal, build an alter and bless and curse themselves, just like Moses told them to.