Shimei was a relative of Saul, the first king of Israel. Shimei ridiculed David when David had to leave Jerusalem because of Absolom’s threat. Saul still had followers. So Shimei was a threat to Solomon’s throne. David instructed Solomon to “bring his gray head down to the grave in blood.” (1 Kings 2:8-9) David wanted vengeance but did not carry it out himself. David told Solomon to kill Shimei.
Solomon devised a way to obey his father. He restricted Shimei to live and stay in Jerusalem with the punishment of death if he left. Shimei did leave after 3 years. Solomon had him put to death. Having a king means that death is a part of them maintaining their throne.
The Lord knows the hearts of humans. He knows that in the fallen state anyone and everyone will violate others, even kill to maintain power. That is why he warned Israel that having a king will make their life harder (1 Sam. 8). However, the person who loves God will resist those impulses by obeying and following Jesus’ teaching.
On the night that Jesus was betrayed, he got up from the table, dressed as a servant, and washed his disciple’s feet. Then he said, “Do you understand what I have done for you?” he asked them. “You call me ‘Teacher’ and ‘Lord,’ and rightly so, for that is what I am. Now that I, your Lord and Teacher, have washed your feet, you also should wash one another’s feet. I have set you an example that you should do as I have done for you. I tell you the truth, no servant is greater than his master, nor is a messenger greater than the one who sent him. Now that you know these things, you will be blessed if you do them.” (Jn 13:12–17)