"Now there was a famine in the days of David for three years, year after year; and David sought the presence of the LORD. And the LORD said, "It is for Saul and his bloody house, because he put the Gibeonites to death." So the king called the Gibeonites and spoke to them (now the Gibeonites were not of the sons of Israel but of the remnant of the Amorites, and the sons of Israel made a covenant with them, but Saul had sought to kill them in his zeal for the sons of Israel and Judah). Thus David said to the Gibeonites, "What should I do for you? And how can I make atonement that you may bless the inheritance of the LORD?" Then the Gibeonites said to him, "We have no concern of silver or gold with Saul or his house, nor is it for us to put any man to death in Israel." And he said, "I will do for you whatever you say." So they said to the king, "The man who consumed us and who planned to exterminate us from remaining within any border of Israel, let seven men from his sons be given to us, and we will hang them before the LORD in Gibeah of Saul, the chosen of the LORD." And the king said, "I will give them." But the king spared Mephibosheth, the son of Jonathan the son of Saul, because of the oath of the LORD which was between them, between David and Saul's son Jonathan. So the king took the two sons of Rizpah the daughter of Aiah, Armoni and Mephibosheth whom she had born to Saul, and the five sons of Merab the daughter of Saul, whom she had born to Adriel the son of Barzillai the Meholathite. Then he gave them into the hands of the Gibeonites, and they hanged them in the mountain before the LORD, so that the seven of them fell together; and they were put to death in the first days of harvest at the beginning of barley harvest. And Rizpah the daughter of Aiah took sackcloth and spread it for herself on the rock, from the beginning of harvest until it rained on them from the sky; and she allowed neither the birds of the sky to rest on them by day nor the beasts of the field by night. When it was told David what Rizpah the daughter of Aiah, the concubine of Saul, had done, then David went and took the bones of Saul and the bones of Jonathan his son from the men of Jabesh-gilead, who had stolen them from the open square of Beth-shan, where the Philistines had hanged them on the day the Philistines struck down Saul in Gilboa. He brought up the bones of Saul and the bones of Jonathan his son from there, and they gathered the bones of those who had been hanged. They buried the bones of Saul and Jonathan his son in the country of Benjamin in Zela, in the grave of Kish his father; thus they did all that the king commanded, and after that God was moved by prayer for the land" (II Samuel 21:1-14).
Saul and his sons had attempted to commit genocide by wiping out a people without God's permission. Worse, these people were under a treaty with Israel and in keeping the terms of the treaty (Joshua 9:15), they were not able to defend themselves. Thus, Saul and his sons were involved in mass murder.
Interestingly, the Gibeonites were not looking for revenge or repayment. They clearly did not like the injustice, but this wasn't about personal revenge. "We have no concern of silver or gold with Saul or his house, nor is it for us to put any man to death in Israel." Years had gone by and they had kept silent until David called for them.
Long ago, when Noah came off the ark, God made a covenant with the world and one of the terms was how murders had to be dealt with. "Surely I will require your lifeblood; from every beast I will require it. And from every man, from every man's brother I will require the life of man. Whoever sheds man's blood, By man his blood shall be shed, For in the image of God He made man" (Genesis 9:5-6). This covenant term had been violated by allowing the murders to go unpunished.
God points out that the killing of a person pollutes the land. "So you shall not pollute the land where you are; for blood defiles the land, and no atonement can be made for the land, for the blood that is shed on it, except by the blood of him who shed it. Therefore do not defile the land which you inhabit, in the midst of which I dwell; for I the LORD dwell among the children of Israel" (Numbers 35:33-34). Notice that to not enforce the death penalty in a purposeful murder case resulted in the ruin of the country. This is why Israel was suffering from a drought.
God had punished Saul for his many sins, but it appears that David was reluctant to bring justice to Saul's sons who had also participated in some of Saul's crimes. I suspect the reluctance came from his love for Jonathan who had died in the same battle that led to Saul's death. When David was on the run after Absalom staged a coup against David, we find that some people had not forgotten that David did not carry out justice as he should have. "Thus Shimei said when he cursed, 'Get out, get out, you man of bloodshed, and worthless fellow! The LORD has returned upon you all the bloodshed of the house of Saul, in whose place you have reigned; and the LORD has given the kingdom into the hand of your son Absalom. And behold, you are taken in your own evil, for you are a man of bloodshed!'" (II Samuel 16:7-8). This is why David refused to have Shimei punished. He knew he was guilty of delaying justice. In fact, it was avoiding punishing his own children that led to Absalom's coup. But even after regaining his throne, David still made no move to carry out justice.
Thus, God finally decided to force David to do his duty as a king. A severe famine struck the land for three years. When David asked God why, he was reminded that Saul's sons had never been brought to justice. David didn't handle the problem himself. He called in the Gibeonites and asked them what would appease them for the wrongs done to their people. They asked for seven of Saul's sons to be put to death for the mass murder. I would assume that seven were still alive who were involved in the attempted genocide. David excluded Mephibosheth, who was Jonathan's son, because of his covenant with Jonathan. Because Mephibosheth was crippled from childhood, he also would not have participated in the genocide.
One of the mothers of the men hanged by the Gibeonites protected the bodies of Saul's sons from birds and wild beasts day and night. Her actions made David realize that he had violated another of God's commands by leaving the bodies of Saul, Jonathan, and the seven other sons unburied. "If a man has committed a sin worthy of death and he is put to death, and you hang him on a tree, his corpse shall not hang all night on the tree, but you shall surely bury him on the same day (for he who is hanged is accursed of God), so that you do not defile your land which the LORD your God gives you as an inheritance" (Deuteronomy 21:22-23). He had their remains gathered up and properly buried.
It was then that God listened to the prayers being made for the land and the drought ended.
The lessons we learn is that God sees that justice is carried out, even for those who have no voice in the government. There are no statutes of limitations with God. He gave David plenty of time to do his duty and he even was given reminders, but eventually, God insisted that the hard tasks had to be done.