The last will and testimony of Yaakov to his twelve children, so too the last will and testimony of David to his young son Shlomo (Solomon).
As Rav Moshe Lichtenstein points out in his article, Yaakov’s message to his children was a blessing and highlighting their special character traits that will feature each and every tribe in the future, in the long range. And contrast King David wants to assure the stability of Shlomo’s kingdom especially in light of the fact, as the text states, “And you shall be a man,” Shlomo, according to the Midrash is only twelve years old.
In David’s testimony, he gives operational orders to his son that the two foes of David’s kingdom, Yoav and Shimi not remain alive for longevity, but rather Shlomo will use his wisdom to assure that they will be “taken care of.” This can be comprehended from a strategic/political point of view that these two will pose a thr4at to Shlomo as they did to David. In addition, it can be understood that both are an ethical stain to the spiritual legacy of the nation of Israel, and therefore people in the generation should not learn from their unlawful actions.
Yet to assure to true stability of the kingdom of Israel, the Torah and it’s Mitzvot, must be guarded, kept, and maintained to it’s utmost to assure a stable kingdom of the House of David. As David truthfully opens up his speech in verses 3 and 4.