Joshua 23–24 records Joshua’s valedictory speech to the children of Israel just before Joshua’s death, which is narrated here and in the next (and final) chapter of the book. The setting for this speech was “a long time after” the territorial allotments, but the exact amount of time is not specified (Joshua 23:1). The immediate audience for this speech was the elders, judges, and officers of Israel (verse 2), whereas Joshua’s audience in the next chapter was Israel as a whole. This concluding speech bookends the speech the Lord gave at the outset of the conquest of Canaan (1:2–9), thus acting as a sort of narrative inclusio that envelops the overarching story.
The main emphasis of Joshua’s speech to the elders of Israel was the importance of covenant faithfulness. Verse 6 depicts Joshua encouraging the elders to “keep and to do all that is written in the book of the law of Moses,” most likely referring to an early version of the book of Deuteronomy. In the next verse, Joshua then stressed how crucial it was for Israel not to turn to the foreign gods of their remaining Canaanite neighbors (verses 7, 12)—an odd comment indeed if we take at face value the totalizing claims made in the book about the Canaanites’ supposed annihilation. In any event, covenant language abounds in this speech, including the specific injunctions for the Israelites to “cleave unto” and “love” Jehovah (verses 8, 11) and the warning that if they transgressed the covenant, they would be cut off from the land (verses 15–16). The covenant context of this speech is made even more explicit in the next chapter, which features a covenant renewal ceremony for the people as a whole.
Throughout his speech, Joshua appeared cognizant of his advanced age and his approaching death (see verse 14), thus accounting for the urgency in his admonitions. In a certain sense, Joshua’s speech might be comparable to those given by Jacob (Genesis 49) and Moses (Deuteronomy 31–33) just before their own respective deaths, thereby linking Joshua back to these figures.
 Compare Joshua 1:8; 8:31, which also speaks of this “book of the law of Moses.” See the commentary for Joshua chapters 1 and 8 for more on the connection between the book of Joshua and the larger Deuteronomistic History.