v1-6: David went to Abimelech the priest, at Nob. He did not specifically seek the mind of he Lord, but he did receive the provision of bread, which was not wrong (Matt 12.3-4, 7; Mark 2.25-26). However, he did obtain a sword, and he also lied to Abimelech; he was not on the king's business.
v7-9: The conversation between Abimelech and David was overheard by Doeg, one of Saul's servants. He reported this to Saul (22.9-10), which Saul took to be a sign that Abimelech was scheming against him (22.13).
David received Goliath's sword. Truly, "there is none like it", but it proved useless to Goliath, and it would be little help to David. In the battle against Goliath, David had trusted in God, here he resorts to human strength.
It is easy to criticise David at this point, but he doubtless felt alone, pursued by Saul, unable to go to Jonathan or Samuel. He even fled to the Philistines, Israel's enemies.
v10: It is sad that the servant of God could find no place of safety amongst God's people.
v11-13: David's reputation amongst the Philistines was strong. Like Samson, he had multiplied their dead. He must have feared for his life. His response was to feign madness before them, hoping they would think him harmless. Achish even described David as “the king of the land,” indicating his evident authority, certainly in battle.
v14-15: Achish was not impressed, but he preserved David's life.
Through this sad situation, David learned lessons; it was at this time that he wrote Psalm 34. He learned to seek the Lord (Ps 34.4); he learned to fear the Lord (Ps 34.9); he taught others to fear Him (Ps 34.11); and he learned the necessity of a broken heart and a contrite spirit (Ps 34.18). Sometimes we have to be brought low to learn lessons from God.
God had delivered David's life (Ps 34.19), but at this time he had no earthly home. He wandered; to Ramah (20.1), to Nob (21.1), to Gath (21.10), to Adullam (22.1), to Mizpah (22.3), to Hereth (22.5).