A Commentary, Critical, Practical, and Explanatory on the Old and New Testaments, by Robert Jamieson, A.R. Fausset and David Brown  at sacred-texts.com
jos 23:1JOSHUA'S EXHORTATION BEFORE HIS DEATH. (Jos 23:1-2)
a long time after that the Lord had given rest unto Israel from all their enemies--about fourteen years after the conquest of Canaan, and seven after the distribution of that country among the tribes.
jos 23:2Joshua called for all Israel--The clause which follows seems to restrict this general expression as applicable only to the officers and representatives of the people. The place of assembly was most probably Shiloh. The occasion of convening it was the extreme age and approaching death of the venerable leader; and the purport of this solemn address was to animate the chosen people and their posterity to a faithful and unswerving continuance in the faith and worship of the God of Israel.
jos 23:3BY FORMER BENEFITS. (Jos 23:3)
ye have seen all that the Lord your God hath done unto all these nations because of you--The modesty and humility of Joshua are remarkably displayed at the commencement of this address. Dismissing all thoughts of his personal services, he ascribed the subjugation and occupation of Canaan entirely to the favoring presence and aid of God; and in doing so, he spoke not more piously than truly. This had been promised (Deu 1:30; Deu 3:22); and the reality of the divine aid was seen in the rapid overthrow of the Canaanites, which had already led to the division of the whole land among the tribes [Jos 23:4].
jos 23:5BY PROMISES. (Jos 23:5-11)
the Lord your God, he shall expel them from before you, as the Lord your God hath promised you, &c.--The actual possessions which God had given were a pledge of the complete fulfilment of His promise in giving them the parts of the country still unconquered. But the accomplishment of the divine promise depended on their inviolable fidelity to God's law--on their keeping resolutely aloof from all familiar intercourse and intimate connections with the Canaanites, or in any way partaking of their idolatrous sins. In the event of their continuing in steadfast adherence to the cause of God, as happily distinguished the nation at that time, His blessing would secure them a course of brilliant and easy victories (Lev 26:7; Deu 28:7; Deu 32:30).
jos 23:11Take good heed, therefore, that ye love the Lord your God--The sum of his exhortation is comprised in the love of God, which is the end or fulfilment of the law (Deu 6:5; Deu 6:11:13; Mat 22:37).
jos 23:12BY THREATENINGS IN CASE OF DISOBEDIENCE. (Jos 23:12)
Else if ye do in any wise go back, and cleave unto the remnant of these nations--As marriage connections with the idolatrous Canaanites would present many and strong temptations to transgress it, these were strictly prohibited (Exo 34:12-16; Deu 7:3). With his eye, as it were, upon those prohibitions, Joshua threatens them with the certain withdrawal of the divine aid in the further expulsion of the Canaanites (a threat founded Exo 23:33; Num 33:55; Deu 7:16).