1 Kings 2:44
The king said moreover to Shimei, Thou knowest all the wickedness which thine heart is privy to, that thou didst to David my father: therefore the LORD shall return thy wickedness upon thine own head; The king said moreover to Shimei, Thou knowest all the wickedness which thine heart is privy to, that thou didst to David my father: therefore the LORD shall return thy wickedness upon thine own head;
The verse belongs to the history of Solomon's reign in the first period of the books of Kings when Israel was still an undivided kingdom, with the books of Kings recounting the kings from Solomon's accession through the Babylonian Captivity. It stands in the first eleven chapters of 1 Kings that contain the life of Solomon, who succeeded David after Saul, before Rehoboam succeeded Solomon and the kingdom was divided into Israel and Judah until Israel was overthrown in 721 B.C. and Judah was taken captive to Babylon.
It is part of the account in 1 Kings 2:1-46 of the settling of Solomon's peaceably received throne after he was crowned king over the unholy ambition of Adonijah to take advantage of David's old age and the disloyalty of Joab. In that settling Adonijah after fleeing to the horns of the altar was pardoned for the time being and later put to death for a further offence and insult to the king, Joab was also put to death, and Abiathar the priest was retired from his office. After Adonijah and Joab were slain, Shimei was also put to death for failing to abide by the conditions set for his life.
Shimei's wickedness was the knowing cursing and abuse he did to David his father, Solomon's father, which his own heart knew. It was done during David's trial in his fear and flight before Absalom. Solomon declared that this earlier wickedness against David would be repaid upon Shimei himself.
His violation of the oath and command and the conditions Solomon had imposed for his life confirmed the wickedness of his heart, and Solomon's sentence followed. He failed to abide by them, and for that failure he died.
Solomon held Shimei responsible and accountable for that wickedness and declared that the LORD would return Shimei's wickedness upon his own head. The Lord repays a person for wickedness done against another by bringing the consequences back upon the wrongdoer's own head. Shimei went down under that answer while David did not.
That return is a universal rule, for every transgression of divine law carries its inherent curse so that no one can walk contrary to God's laws without suffering. That cursing belonged to the troubles in David's family growing out of his multiplying wives to himself, where idleness, luxury and jealousy developed unenviable characters around Absalom's ambition, treachery, defeat and death. Yet even then David's kindness to the house of Saul remained in evidence.
Shimei's punishment is included among the later troubles and deaths in David's family that fulfilled the judgment that violence would remain in David's house. 1 Kings 2 is part of the subsequent history of David proving that his great wickedness in the case of Uriah was not covered up or excused but was openly recorded with Nathan's terrible denunciation. It shows the judgments that came upon David as the complete accomplishment of that prophetic denunciation.