Toward the beginning of the parasha, the Torah instructs of the use of the special recipe of the shemen hamishcha (oil of anointment) to be used for sanctifying the vessels of the Mishkan and for Aharon and his sons for His service (Shemot 30:22-30). The Torah continues (ibid. 33) that it is strictly forbidden to use this oil for other purposes, including placing it on the body of a zar (a "stranger," usually meaning a non-kohen).
It is thus a surprise to find that shemen hamishcha was used to anoint Shaul (Shmuel I, 10:1) and David (ibid. 16:1) as kings. After all, neither of them was a kohen! Rashi (Shemot 30:33) seems to hint at an answer, as he says that it is forbidden to put the oil on a zar "not for the purposes of priesthood or kingdom." In other words, a king is not considered a zar here. This is a difficult answer, though, as whenever a zar is forbidden to do something, a king is included in the prohibition (see Shabbat 31a).
The Ibn Ezra cites an answer from a source from the Geonim – there was a tradition that a special exception was made for David and his descendants. In other words, it is based on the concept that a prophet is allowed to declare a limited exception to halacha for the needs of the time.
The Ramban (Shemot 30:33) gives a more fundamental answer. The use of the holy oil, which was given "for Me for generations" (see Shemot 30:31), was supposed to be used for those who are particularly set aside for Hashem. Whoever is not in that special category is considered a zar in this context. Just as the kohen was anointed to be Hashem’s, so too the king was anointed to be Hashem’s. This, he says, is in line with the pasuk: "I found my servant David, with the oil of My holiness I anointed him." The Ramban explains that since both the kohen and the appointed king are called mashiach (as we find in regard to both Shaul and David), it is appropriate that they use shemen hamishcha.
The conclusion we can arrive at from the Ramban is that the kingdom of Israel, i.e., its political leadership, is part of the "leadership of sanctity." Any attempt to separate between the Torah/religion and between the government in Israel will not work and is against Jewish tradition. One should prefer to connect the two and view the entire leadership as part of the worlds of Torah, spirituality, and the public sphere.
What then is the point of anointing the king with oil if we have seen several times that it is the nation who chooses the king? Let us suggest the following. Every leader has to make decisions based on calculations of gain and loss. At times, especially at critical times, there is a need for divinely provided insight, which we could call "divine assistance" or "the spirit of Hashem," in order to decide. This ability gives the leader a special standing. David and his offspring received this present, for which the anointment is part of the preparation. Let us pray that our public leadership will be blessed with such assistance, even if we no longer have the shemen hamishcha.