God in His providence will prevent the great folly of David and lead him back to Him. He makes sure that David does not have to come along in a battle of the Philistines against the people over whom He anointed David as king. That deliverance is not due to anything of David. He can only praise the LORD for His grace.
The LORD uses the memories of the other Philistines to put pressure on Achish to send David home. The LORD works in secret for David by turning the hearts of his enemies against him. Thus the Lord can also work for us in secret by working enmity against us in the hearts of men. That is a way to deliver us from a situation from which we cannot deliver ourselves and in which we may have been landed by our unfaithfulness.
Achish tries to keep David with him by giving a resounding testimony of his full dedication to the cause of the enemy. But the pressure is getting too high. It was not unusual for Israelites to serve in the armies of the Philistines (1Sam 14:2121Now the Hebrews [who] were with the Philistines previously, who went up with them all around in the camp, even they also [turned] to be with the Israelites who [were] with Saul and Jonathan.). At the decisive moment, however, they left and joined Saul again. David could do the same. They emphasize their distrust in David by reminding Achish of the testimony of David and citing it in full (1Sam 18:77The women sang as they played, and said,
“Saul has slain his thousands,
And David his ten thousands.”
). They know that well. On a previous occasion that David has been in their land, they have also referred to it (1Sam 21:1111But the servants of Achish said to him, “Is this not David the king of the land? Did they not sing of this one as they danced, saying,
‘Saul has slain his thousands,
And David his ten thousands’?”