David took the head of the Philistine [Goliath], and brought it to Jerusalem. ... And as David returned from the slaughter of the Philistines, Avner took him, and brought him before Shaul with the head of the Philistine in his hand. (Shmuel Alef 17:54-17:57)
After killing Goliath, David took the dead giant's head to Jerusalem, to show off to the king Shaul.
In Shmuel Bet chapter 5 we learn that Jerusalem was a Jebusite city, which was only conquered and made the capital of Israel after David became king! So what is David doing, years beforehand, bringing Goliath's head to a non-Israelite city? Would a Mossad agent have brought Imad Mugniyah's head to show off to Ehud Olmert in, say, Beirut or Cairo?
To understand this, I think we have to look at the context of David's conquest of Jerusalem. In chapters 2 to 4 there is a bloody civil war between David and Shaul's son Ish-Boshet, each of whom intends to be king over all Israel. At the beginning of chapter five, the Ish-Boshet side finally capitulates and all of Israel recognizes David as king. The very next story is David's conquest of Jerusalem.
I think it's no coincidence that Shaul happened to visit the same city, which David conquered right after subjugating Shaul's tribe and dynasty. Jerusalem is located right on the border between the tribes of Binyamin and Yehudah. In the rivalry and conflict between these tribes, represented by the conflicts between Shaul/Ish-Boshet and David, it is hard to imagine that Jerusalem remained impartial. Presumably, at an early date Jerusalem declared itself a close ally of Binyamin and Shaul's dynasty. Thus Shaul could be expected to frequently visit Jerusalem (and showing them Goliath's head is a good way of emphasizing Israelite strength, and how it's worth it to stay allied with Shaul). And when open warfare broke out between Binyamin and Yehudah, Jerusalem allied with the former, and remained opposed to David until he finally conquered it.
David then declared Jerusalem to be the national capital, in which the Temple would later be built. From a practical perspective, this meant putting the past threats to his power right under his nose, where he could ensure they did not threaten him again. At the same time, choosing a capital on the border between Yehudah and Binyamin symbolized the reconciliation between those tribes, and the peace which he hoped would prevail throughout the entire nation.