A person who desires to abide in the presence of God has to be an upright person who lives all his life according to what God has revealed. God revealed to David a challenging aspect of being such a person:
Psa 15:4 In whose eyes a vile person is contemned; but he honoureth them that fear the LORD. He that sweareth to his own hurt, and changeth not.
This revelation teaches that when a righteous person makes a promise to someone, he is to keep his word even though it may cost him personally to do so.
Joshua 9 provides an excellent illustration of such uprightness. Because they had failed to ask counsel from God (Josh. 9:14), the Israelites were deceived by the people of Gibeon into making a league with them (Josh. 9:6) and making peace with them so that they would allow them to live (Josh. 9:15).
Although they had been deceived into doing so, the Israelites had to honor the commitment that they swore to them by the Lord:
Jos 9:19 But all the princes said unto all the congregation, We have sworn unto them by the LORD God of Israel: now therefore we may not touch them. 20 This we will do to them; we will even let them live, lest wrath be upon us, because of the oath which we sware unto them.
We should learn from this account that we must be very careful what promises we make to people and that we must keep our word when we do so in spite of how it may hurt us to do so.
Joshua 9 thus provides us with a sobering, excellent illustration of the necessity of keeping our word.