M’lochim I 2:1
Dovid’s unfinished business dealt with situations of personal loyalty and treachery. In order for the succession of the throne to be secure and peaceful, Dovid identifies two key individuals who had betrayed him during his 40 years as King – King David’s General, Yoav ben Tzeruah, and Shlomo’s own Rebi, the great scholar Shimi ben Gera. In addition, he set apart the family of Barzillai the Gileadite for special royal consideration and reward.
Dovid Hamelech was not interested in revenge. Dovid, the father of Mashiach, was not consumed with anger. Dovid, the sensitive poet and magnificent singer, was interested in justice and the future well being of his nation. It was essential that he teach the young Shlomo the meaning of strong leadership and how to care for a problem, before it becomes a crisis.
Undoubtedly, it would have been easy for Dovid Hamelech to forgive those who had betrayed him, especially at the very end of his life; but that isn’t the quality of leadership, which brings eventual redemption, and the building of the Bais Hamikdash. As the King, Dovid and Shlomo had to be devoted to Hashem’s Torah, social justice, and the eternity of the nation.