Achish was king of Gath during David’s time. David gained his trust via deceit Andrew he was granted asylum in Gath while on the run from Saul.
Achish trusted David and said to himself, “He has become so odious to his people, the Israelites, that he will be my servant forever.” 1 SAMUEL 27:12
Achish must not have been a very good judge of character, because David seems to have had him wrapped around his little finger.
Achish was the king of the Philistine city of Gath. We first read of Achish when David fled to him from Saul, who was trying to kill him out of jealousy. David sought asylum with Achish, but he quickly feared for his life in Gath as well, because his great reputation as a mighty warrior of Israel had preceded him there. So David pretended to be insane, and Achish left him alone (1 Samuel 21:10–15).
David soon left Gath and gathered six hundred men with him while he lived in the cave of Adullam and elsewhere throughout Judah. He later returned to Gath to escape Saul, and Achish granted David the town of Ziklag as his home. David continued to deceive Achish by attacking various Philistine villages and telling Achish that he had attacked Israelite villages (1 Samuel 27). Achish became so trusting of David that he included his men among the Philistine forces that were gathering for battle against Israel in the Jezreel Valley. But the other Philistine commanders smelled a rat, and they wisely forbade David and his men to join them (1 Samuel 28–29).
David had dealings with the city of Gath even before he met Achish.
The giant Goliath, whom the young David defeated with his sling, was from Gath, and David had retrieved Goliath’s sword just before going to Achish at Gath.