The casting or drawing of lots is a practice called sortition. It was a very common way of discerning divine will. I think it was done by the Greeks and Romans, too, and there are other occurrences of sortition in the Bible. Take, for example, the casting of lots in the Book of Jonah, whereby the mariners determine that Jonah is the cause of the storm.
And they said to one another, “Come, let us cast lots, that we may know on whose account this evil has come upon us.” So they cast lots, and the lot fell on Jonah. (Jonah 1:7 ESV)
Another important example of drawing lots happens later on in Joshua. While Caleb receives Hebron for the faithful account he had given Moses, most of the other tribes receive their inheritance of land by lot.
Their inheritance was by lot, just as the Lord had commanded by the hand of Moses for the nine and one-half tribes. (Joshua 14:2)
This decision is based on what God had said to Moses.
And the Lord spoke to Moses in the plains of Moab by the Jordan at Jericho, saying, “Speak to the people of Israel and say to them, When you pass over the Jordan into the land of Canaan, then you shall drive out all the inhabitants of the land from before you and destroy all their figured stones and destroy all their metal images and demolish all their high places. And you shall take possession of the land and settle in it, for I have given the land to you to possess it. You shall inherit the land by lot according to your clans. To a large tribe you shall give a large inheritance, and to a small tribe you shall give a small inheritance. Wherever the lot falls for anyone, that shall be his. According to the tribes of your fathers you shall inherit. But if you do not drive out the inhabitants of the land from before you, then those of them whom you let remain shall be as barbs in your eyes and thorns in your sides, and they shall trouble you in the land where you dwell. And I will do to you as I thought to do to them.” (Numbers 33:50-56)
Okay, now, with all that said, you can see how the casting or drawing of lots is an important practice of the time. You can also see how it enhances the story in chapter 7 of Joshua. This unlikely process of drawing a tribe by lot, and then a clan by lot, and then a household by lot, and then an individual by lot, eventually reveals the culprit. The drawing of lots was intended to reveal God's will, and it did reveal God's will, as it uncovered Achan. The process must have been time-consuming. Achan did not confess during any time of the process. So it might be a way of showing how inexorable God's justice can be. But in the Book of Jonah we also see that God can turn from his wrath if a sinner repents. The entire city of Nineveh repents in Jonah, every person and beast wearing sackcloth and ashes, and so God decides not to destroy the city. As the other answer states, this climactic process of drawing by lot may have (1) given Achan a chance to repent and (2) shown how inevitable God's justice can be.