Continuing with the story of young King David and his battles with King Saul, we learn that David did not allow his men to harm Saul, even though he had many opportunities. He refused to raise his hand against the Lord's anointed.
1 Samuel 24:6-7 New King James Version (NKJV)
6 And he said to his men, “The Lord forbid that I should do this thing to my master, the Lord’s anointed, to stretch out my hand against him, seeing he is the anointed of the Lord.” 7 So David restrained his servants with these words, and did not allow them to rise against Saul. And Saul got up from the cave and went on his way.
David could have been offended, but he constantly tried to appeal to Saul to break off his attacks. He did not swallow the bait of Satan to be offended by Saul. We also need to mature to the point where we will not be enticed by the bait. Paul the apostle describes it in Romans.
Romans 12:19 New King James Version (NKJV)
19 Beloved, do not avenge yourselves, but rather give place to wrath; for it is written, “Vengeance is Mine, I will repay,” says the Lord.
Young king David wanted to get back in favor with Saul and he might have perceived that he was being mistreated. So he tried to demonstrate his loyalty to his master.
We must determine once and for all that we are not going to retaliate even if others are out to get us.
In a sense, God was testing David's heart. And David would not take the bait. God even put Saul's army to sleep so David could approach Saul in the middle of their camp. God was testing David to establish his throne in righteousness.