1 Samuel 28:2

And David said to Achish, Surely thou shalt know what thy servant can do. And Achish said to David, Therefore will I make thee keeper of mine head for ever.

David had placed himself under Philistine protection without seeking God's counsel. The favor shown him by the Philistines came from selfish motives, for they remembered that he had killed Goliath and hoped to separate his forces from Saul's army and turn him against Israel. With David and his force thus positioned among the Philistines, Saul feared David would use the opportunity to take revenge for the wrongs he had suffered.

When pressed to join in fighting Israel in the coming war, David answered evasively that Achish would see what his servant could do. He had no intention of attacking his own people, though he had not yet settled what he would do. Achish took David's words as a promise of military help in the coming war.

In return Achish promised him a permanent position of great honor as a high official at the Philistine court, believing David would serve him in the war, and this is what being keeper of his head forever means. To repay the kindness of the Philistines with deception was poor policy.