The exciting story of David and Goliath illustrates what it was that God saw in David's heart that led Him to choose David for the position of king. It also shows how and why others in Israel began to notice David. David fought the Lord's battles as Samuel did (ch. 7). He also did so as Saul, God's previously anointed king, had done (chs. 10-11, 14-15).
Saul's defeat of the Ammonites (11:1-11) followed Saul's anointing (10:1). Similarly David's defeat of the Philistines (ch. 17) follows the record of his anointing (16:13). Both victories demonstrate God's blessing on His newly anointed leaders.