In the blessings that open our parasha, Hashem promised: "I will place my Sanctuary in your midst" (Vayikra 26:11), and Chazal identify this as the Beit Hamikdash (Sifra, Bechukotai 1:3; Rashi). In order for the people to begin their preparations to accept this blessing, first the location of the Beit Hamikdash had to be decided based on prophecy (see Devarim 12:5). The Torah does not state where this place was to be, and this uncertainty continued for more than 400 years after the Exodus from Egypt.
The steps towards discovery began in earnest as the monarchy was emerging, at the time of Shmuel, Shaul, and especially David, even before the latter had the crown put on his head. David fled from Shaul and went with Shmuel to Nayot in the Rama. Shaul found out and sought them, but along the way he was overcome by the "spirit of Hashem," and began to prophesy (Shmuel I, 19:18-23).
Chazal (Yalkut Shimoni, Shoftim 910) understood that the name of the place Nayot in Rama was a hint to the Beit Hamikdash, which was rama (in a high place) and was the noy (adornment) of the world. The place was on the joint border of the tribes of Binyamin and Yehuda. This would enable the drawing together of these critical factions in the nation, representing the descendants of the matriarchs Rachel and Leah. Therefore, when David became king over all of the nation, he captured Yerushalayim and appointed it as the eternal capital of the Jewish nation, united and unifying – the city to which all are connected (see Tehillim 122:3).
Unfortunately, at the moment that Avshalom rebelled against his father David and received popular support, David did not want to remain in the city and fled (see Shmuel II, 15:14). The head kohanim, Tzadok and Evyatar, wanted to join David with the aron from the Mishkan containing the luchot habrit. However, David told them to return the aron to Yerushalayim, where David would return if Hashem would have him merit it (ibid. 25-26).
David, the great believer, did not give up on the dream of Yerushalayim as the eternal capital – the center of the nation from a spiritual and political perspective. By leaving the city behind intact, he was announcing that it must remain the center even without him. "If I am correct, I will be able to return; if I am not correct, I will not return, but Yerushalayim will remain the center."
David is the one who set the formula: while leaders come and go, the capital remains. Because of his stance, David became an eternal part of our history. "Yerushalayim, for generation after generation" (Yoel 4:20). "David King of Israel lives and remains."