Complete Commentary on the Whole Bible, by Matthew Henry, at sacred-texts.com
(Jos 8:1, Jos 8:2) God encourages Joshua.
(v. 3-22) The taking of Ai.
(Jos 8:23-29) The destruction of Ai and its king.
(Jos 8:30-35) The law read on Ebal and Gerizim.
When we have faithfully put away sin, that accursed thing which separates between us and God, then, and not till then, we may look to hear from God to our comfort; and God's directing us how to go on in our Christian work and warfare, is a good evidence of his being reconciled to us. God encouraged Joshua to proceed. At Ai the spoil was not to be destroyed as at Jericho, therefore there was no danger of the people's committing such a trespass. Achan, who caught at forbidden spoil, lost that, and life, and all; but the rest of the people, who kept themselves from the accursed thing, were quickly rewarded for their obedience. The way to have the comfort of what God allows us, is, to keep from what he forbids us. No man shall lose by self-denial.
Observe Joshua's conduct and prudence. Those that would maintain their spiritual conflicts must not love their ease. Probably he went into the valley alone, to pray to God for a blessing, and he did not seek in vain. He never drew back till the work was done. Those that have stretched out their hands against their spiritual enemies, must never draw them back.
God, the righteous Judge, had sentenced the Canaanites for their wickedness; the Israelites only executed his doom. None of their conduct can be drawn into an example for others. Especial reason no doubt there was for this severity to the king of Ai; it is likely he had been notoriously wicked and vile, and a blasphemer of the God of Israel.
As soon as Joshua got to the mountains Ebal and Gerizim, without delay, and without caring for the unsettled state of Israel, or their enemies, he confirmed the covenant of the Lord with his people, as appointed, Deuteronomy chapters 11 and 27. We must not think to defer covenanting with God till we are settled in the world; nor must any business put us from minding and pursuing the one thing needful. The way to prosper is to begin with God, Mat 6:33. They built an altar, and offered sacrifice to God, in token of their dedicating themselves to God, as living sacrifices to his honour, in and by a Mediator. By Christ's sacrifice of himself for us, we have peace with God. It is a great mercy to any people to have the law of God in writing, and it is fit that the written law should be in a known tongue, that it may be seen and read of all men.