What Joshua says here may also be a repetition of what Moses said toward the end of Deuteronomy after listing the sanctions of blessings and curses: "And when all these things come upon you, the blessing and the curse, which I have set before you, and you call them to mind among all the nations where the LORD your God has driven you, and return to the LORD your God…" (Deut. 30:1-2). This is a prophetic statement. Moses told Israel that "all these things" would come upon them, both the blessings and the curses and generally in that order. God's blessings would come in the earlier years of their life in the Promised Land. This period would be followed by a period of the curses, leading to their exile from the Promised Land, scattered all throughout the Gentile nations. What Joshua says in our passage is similar: after having done Israel good, God would punish them for forsaking the Lord and serving foreign gods (v. 20).
Was it a good thing for the Israelites to insist on pledging their allegiance to God? Was this an act of defiance, not believing what Joshua the servant of the Lord said about them and their future? Was this like what their previous generation did at Kadesh-barnea? Remember? There God condemned them to die in the wilderness when they refused to enter the Promised Land, accusing God of bringing them out of Egypt only to kill them in Canaan. Belatedly, they regretted what they did and decided to fight their way into Canaan. But that was against God's explicit command not to do it. And they were crushed by the Amalekites and the Canaanites who lived there. But here in our passage, Joshua hears their pledge and officiates Israel's covenant renewal with God.