The Philistines were descendants of Ham (Gen 10:14), and they lived in the land of Canaan along the southern coast of Mediterranean Sea (Gen 10:19, Gen 26:1, Ex 13:17, Ex 23:31, Josh 13:3, 1Sam 6:17). They were perpetual enemies of Israel as far back as the days of Isaac (Gen 26:14-18). This was especially the case during the days of Saul and David. They were part of the inhabitants of Canaan that should have been destroyed. One of their main cities was Gaza (Jud 16:1 & 21, 1Sam 6:17, 2Ki 18:8, Jer 47:1). Today this area is still called the Gaza strip, and the people who live there are called Palestinians which means Philistines. This is a main Palestinian stronghold against Israel.
Saul was chosen by God to be the first king of Israel (1Sam 8-10). However, he made two major errors which caused him to be rejected as king (1Sam 13, 1Sam 15). God chose David to replace him (1Sam 16). Initially Saul favored David and made him his armorbearer and his son-in-law (1Sam 18). However, Saul became jealous of David and saw him as a threat instead of an ally (1Sam 18-26).
When the Philistines ruled over the Israelites, they took all their weapons of war away (1Sam 13:19-22). They were not even allowed to have metalworkers who could make or sharpen their farming implements. It was a way to control the Israelites and prevent them from defending themselves against their oppressors. When Saul began to resist them, only he and his son Jonathan had proper weapons.
Goliath had a spear and a sword, and after David killed him with his own sword, he kept it (1Sam 17:54, 1Sam 21:8-9). After David’s victory over Goliath and the subsequent Israelite victory over the Philistines (1Sam 17), Saul had a spear, also called a javelin (1Sam 18:10-13). In his narcissistic insecurity and jealousy over David, he tried to kill him with it twice (1Sam 19:9-10). After the second attempt, David not only fled the room, he ran for his life never to return to the service of Saul (1Sam 20). Two days later, he also tried use his spear to kill his own son Jonathan whom he planned to make king after him because he was loyal to David (1Sam 20:33).
Saul made at least twenty attempts on David’s life, but God kept delivering him (1Sam 18-26). Saul brought his spear on this campaign (1Sam 22:6). Although David could no longer trust Saul, he respected the fact that God had chosen him to be king, even though God had already chosen him to replace him. He left it in the Lord’s hands to sort that out. He had two significant opportunities to kill Saul but did not (1Sam 24 & 26). The second time, Saul and his army were sleeping in the field. David and one of his men named Abishai snuck into the camp. Saul’s spear was stuck in the ground right next to his head. Abishai offered to use it kill Saul, but David forbade him. However, David took it and Saul’s water bottle and left. He went up a hill a distance away and called out to Abner, Saul’s bodyguard. He showed that he had an easy opportunity to kill Saul and did not, with the proof being Saul’s own spear that he had tried to kill David with twice. He told Saul to send a young man to retrieve his spear.
David returned the very weapon Saul had been using to try to kill him. This seems to be contrary to rationality. Not many people would spare Saul or return his spear. Not many people would have returned to the king’s chamber after the first attempt to kill them. Can you imagine being in the room with the person who tried to kill you while they are sitting there with the murder weapon in their hand? This says something about the character of David. He trusted God, respected authority, was not a position seeker, and forgave. He was not foolish or gullible, but he was not bitter or vengeful. He did not take matters that belonged to God into his own hands. This is an extreme example, but one we can all learn from.