Shimei's story begins in 2 Samuel 16 with his cursing of David as David was in mourning and in distress over the death of his son Absalom.
And as David and his men went by the way, Shimei went along on the
hill's side over against him, and cursed as he went, and threw stones
at him, and cast dust. (2 Samuel 16:13, KJV)
David did not choose at that time to punish Shimei, even though he had both cursed and thrown stones at David and his men. Three chapters later, one of his men made inquiry of David regarding this.
But Abishai the son of Zeruiah answered and said, Shall not Shimei be
put to death for this, because he cursed the LORD's anointed? (2
Samuel 19:21, KJV)
To which David had responded:
And David said, What have I to do with you, ye sons of Zeruiah, that
ye should this day be adversaries unto me? shall there any man be put
to death this day in Israel? for do not I know that I am this day king
over Israel? (2 Samuel 19:22, KJV)
But, as with Joab, David gave some instructions to his son Solomon that Shimei not be allowed to die in peace.
And, behold, thou hast with thee Shimei the son of Gera, a Benjamite
of Bahurim, which cursed me with a grievous curse in the day when I
went to Mahanaim: but he came down to meet me at Jordan, and I sware
to him by the LORD, saying, I will not put thee to death with the
sword. Now therefore hold him not guiltless: for thou art a wise man,
and knowest what thou oughtest to do unto him; but his hoar head bring
thou down to the grave with blood. (1 Kings 2:8-9, KJV)
Solomon was but carrying out his father's last wishes. He was performing a duty that had been commanded of his father.
Conclusion
Shimei's death was a deserved, albeit delayed, punishment that was given by David's orders after his death. It was not because he posed any threat to Solomon's kingdom, nor because of any particular wrong done to Solomon himself.