The covenant between YHWH and Israel has been shown to correspond closely with a form of treaty between a suzerain (feudal lord) and a vassal known in second millennium BCE. The suzerain state is stronger than the vassal state and usually the relationship is established after the suzerain defeats the vassal or ransoms the vassal from another state. For Israel’s case, YHWH ransomed Israel from Egypt and hence Israel is his. After the vassal acknowledge the lordship of the suzerain state, the vassal needs to pay tribute to the suzerain, while on the other hand the suzerain has an obligation to protect the vassal from foreign assaults. Of course, the vassal is expected to help the suzerain as well in any war the suzerain is involved in.
In some cases, the relationship could be initiated as well by a voluntary surrender by the eventual vassal. An example would be the Gibeonites. Joshua and co. had just defeated Jericho and Ai and the people of Gibeon could very well be his next target. So, to avoid the same fate as Jericho and Ai, the Gibeonites decided to surrender themselves and became the servants of Israel. The Israelites must not know that the Gibeonites are the people of the land, though, since the Israelites are obliged to slay the whole people in Canaan. So they deceived the Israelites into making a treaty (or, a covenant) with them: “We have come from a distant country; make a treaty with us.” (Jos 9.6) And the Israelites were (ironically, since they were the descendants of the Great Deceiver himself, Jacob) deceived, indeed. They made a treaty with the Gibeonites; the Gibeonites became their vassals and had to serve the Israelites (they became the woodcutters and water carriers for the community).
Soon enough the Israelites realized that the Gibeonites were actually locals. Crap. Well, but you need to respect the covenant that you had made with the Gibeonites. The covenant can’t be annulled. So, first the Gibeonites escaped the fate of Jericho and Ai (so, as a consequent, the Israelites wouldn’t be able to fulfill his task fully). And, the Israelites had an obligation towards the Gibeonites as well. If the Gibeonites were attacked by other states, the Israelites must protect them. And they did. The Gibeonites were attacked by the king of Jerusalem, the king of Hebron, the king of Jarmuth, the king of Lachish, and the king of Eglon. These fellow local kings were upset because the Gibeonites (the locals and supposedly their ally) had made peace with the Israelites (the foreigners and their potential invaders). Naturally, the Gibeonites demanded their right as the Israelites’ vassal: “Do not abandon your servants. Come up to us quickly and save us! Help us, because all the Amorite kings from the hill country have joined forces against us.” (10.6) Fulfilling their duty as a suzerain, the Israelites obliged. They were supposed to fight these kings, by the way, but now they needed to do it earlier and perhaps against a larger coalition than what was expected. Perhaps they had planned to defeat them one by one. But now they didn’t have any other choice. They would fight these kings together; thanks to the Gibeonites.