Saul wanted David dead, but God wanted him alive. Who wins conflicts like that? One of the tools that God used to help protect David was Saul's own son, Jonathan. He warned David about the continuing danger and even spoke up for David and defended him before Saul... with some temporary success. And so, for a while David and Saul got along ok. But, although David served him well, once an evil spirit came over Saul, he returned to his former hatred for David and again tried to kill him. It was a pattern of love and hate that would continue between the 2 men for a long time.
In this chapter, it is recorded that Saul tried to impale David with his javelin, just as he had attempted earlier. Then he sent soldiers to kill David in his bed. If it hadn't been for Michal (his wife) warning him and helping him to escape through a window, he would have died there in his own home, or he would have been brought to Saul to be murdered at the hand of the king.
But, by God's grace he escaped to Naioth to stay with the prophet Samuel. When Saul tried to kill him there, God prevented it by miraculously causing Saul and all of his helpers to be overcome with the power of the Holy Spirit so much so that they virtually lost control of themselves and couldn't carry out their own intentions. So, in the will of God, David was invincible.