what does the bible say?
Jericho was the first city conquered in the Promised Land and, before capturing it, God told the people to devote it to destruction (Joshua 6:17). Being so devoted meant that nothing was to remain, and they were to keep nothing except what was collected for God’s sanctuary (Joshua 6:18–19). That was a way to both raze a town and worship God through the act.
When Israel first fought Ai, the second city, they failed (Joshua 7:4–5). They discovered that Achan had violated God’s command when taking Jericho and had kept some items for himself (Joshua 7:20–21). Though perhaps of some value, the issue was not the value, but that he had taken something devoted to destruction (Joshua 7:11–12a), thereby making Israel now devoted to destruction (Joshua 7:12b), and thus God withheld His help when facing Ai (Joshua 7:12c).
Because Achan did this, the items he took, along with him and his entire family, were destroyed (Joshua 7:24–26a). This appeased God’s wrath against Israel (Joshua 7:26b), and subsequently defeated Ai at the second attempt (Joshua 8:1–2).
Believers are under a new covenant, so God doesn't deal with us the same way He dealt with Israel. However, sin still has corporate effects. Thus, the church must maintain purity by dealing with sinning believers, and we must strive not to sin, knowing that our sin hurts not only us but others around us.