On the face of it my title question seems silly. David did it with rock and sword. But go with me into the society of that day and see what led up to that momentous event. Let us start with a look at I Samuel 13:19-22
19 Now there was no smith found throughout all the land of Israel: for the Philistines said, Lest the Hebrews make them swords or spears:
20 But all the Israelites went down to the Philistines, to sharpen every man his share, and his coulter, and his axe, and his mattock.
21 Yet they had a file for the mattocks, and for the coulters, and for the forks, and for the axes, and to sharpen the goads.
22 So it came to pass in the day of battle, that there was neither sword nor spear found in the hand of any of the people that were with Saul and Jonathan: but with Saul and with Jonathan his son was there found. (KJV)
A clearer phrasing can be found in the Good News Translation.
19 There were no blacksmiths in Israel because the Philistines were determined to keep the Hebrews from making swords and spears. 20 (The Israelites had to go to the Philistines to get their plows, hoes, axes, and sickles sharpened; 21 the charge was one small coin for sharpening axes and for fixing goads, and two coins for sharpening plows or hoes.) 22 And so on the day of battle none of the Israelite soldiers except Saul and his son Jonathan had swords or spears.
Can you imagine an entire army, nay, and entire nation disarmed by its enemies until only the king and most prominent prince even had a sword or spear? Things were desperate throughout Israel. An entire generation was untrained and unequipped to wage conventional war. The Philistines seemed to have placed their enemies, the Israelites, in an untenable situation. Even if somehow they learned to use swords, they had no swords to use. If they had swords they would not know how to use them. They were in a circular quandary. Any weapons Saul’s army might have could only be crude farming implements ill suited to battle. This makes it very clear why David, when dressed in Saul’s armor declined to wear it to battle.
I Samuel 17:39 And David girded his sword upon his armour, and he assayed to go; for he had not proved it. And David said unto Saul, I cannot go with these; for I have not proved them. And David put them off him. (KJV) Or, as it says in the New International Version: “I cannot go in these,” he said to Saul, “because I am not used to them.” So he took them off.
No wonder the entire army was frightened. There were none of them skilled with a sword. Even if they had been, the giant had them on reach and strength. They would be smitten dead before they could get within striking distance. However, the lack of conventional weapons had forced certain Israelites to develop unconventional skills for self defense and protection of their flocks and crops. David was among those who had become expert with the sling.
Long hours of practice in the Judean hills had honed his ability to put a stone exactly where he wanted it. A sword would have forced him in so close it would have been suicide to try. The sling gave him the advantage of working room and a stand-off distance for safety. I am sure God could have brought deliverance some other way, but because the Philistines had forbidden the ownership of swords David had been forced to learn a skill that made his victory over Goliath possible.
In the long run it was the Philistines who killed Goliath. Their policy put the sling and its skill in the hand of David.
Remember this: Every excess has within itself the seeds of its own destruction.