As a boy, David was anointed by Samuel to be the second king of Israel. However, Saul was still king for a while yet. (The drama there is a much longer story.)
While David was still a teen, he went to visit his brothers on the battlefield as they faced off against the Philistines. But no fighting was being done; just a giant in the valley cursing the Israelites and their God. The deal was that instead of an all-out war, Goliath, the giant Philistine, would face any one of the Israelites to decide the victory. No one would do it even when King Saul offered great wealth and his daughter in marriage.
When David arrived, he saw the scene and was highly offended at taunting. He bravely volunteered. He was a shepherd boy and, with a sling, had killed lions and bears to protect the sheep. He knew that his skill and God's strength would be enough to dispose of this enemy. They tried to put the king’s armor on him but it was way too big.
Goliath was covered in armor and armed with a sword, a javelin and a shield.
When the giant saw the teenager, his trash talk increased.
Then David told him of his plan to dispose of him.
Then David put a rock in his sling and quickly sank it into the enemy’s forehead.
David, with the power of God, defeated the enemy.
(1 Samuel 17 has more of the details.)