After 3 years of famine in Israel, David discovered that the cause was a divine curse. Back in the days of Joshua, the Jews had made a promise to the Gibeonites that they would never fight against them. However, King Saul, (in his military zeal) had killed many of the Gibeonites. So, God reimbursed Israel for their breach of promise by holding back His blessings from them... as I said, for 3 years.
When David realized what the problem was, he inquired from the Gibeonites to find out what could be done to satisfy their hearts and to pacify God's anger. They asked for 7 men from Saul's household to be delivered to them to be executed. Among those 7, David gave to them 5 of his own step-sons. (All 5 were children of Michal from the years when David had been in exile). It seems that from the day that he brought the Ark into Jerusalem, the rift between David and Michal had remained very deep indeed.
After those 7 descendants of Saul had been killed, one of Saul's former concubines spent several months keeping vigil over the bodies of those men. She kept the birds and the beasts off their carcasses as the flesh decayed. When David heard about that, he respectfully buried those men's bones along with the bones of Saul and Jonathan. When all of that was done, the famine ended. God's justice prevailed; He was appeased.
Now, the second half of this chapter is devoted to the greatest exploits of some of David's greatest military men against some of Israel's most prominent enemies. They had had no business fighting the Gibeonites previously, but there were 4 Philistine giants who were fair game.