Positive commandment · Mitzvat Aseh #35 of 613
To anoint the High Priests and kings with the anointing oil
למשוח כהנים גדולים ומלכים בשמן המשחה
The verse · Shemot 30:31
וְאֶל־בְּנֵי יִשְׂרָאֵל תְּדַבֵּר לֵאמֹר שֶׁמֶן מִשְׁחַת־קֹדֶשׁ יִהְיֶה זֶה לִי לְדֹרֹתֵיכֶם
“And thou shalt speak to the children of Yisra᾽el, saying, This shall be a holy anointing oil to me throughout your generations.”
The Rambam’s words
To anoint the High Priests and kings with the anointing oil, as [Exodus 30:30-31] states: "[Anoint Aaron....] This shall be sacred anointing oil."
למשוח כהנים גדולים ומלכים בשמן המשחה, שנאמר: "שֶׁמֶן מִשְׁחַת קֹדֶשׁ יִהְיֶה זֶה" (שמות ל, לא).
Why · Sefer HaChinuch #107
Anointing the high priest and the kings of the House of David with anointing oil
“It is from the roots of the commandments that G-d, blessed be He, wanted us to do an act, ourselves, on the day that we go up to be inaugurated to the honor of His holy service that indicates greatness and praise in us.”
Who & when
“And [it] is practiced at the time of the [Temple], and it is from the commandments that are impingent upon the community — like the building of the [Temple] and its vessels.”
Where in the Mishneh Torah
Hilchot Vessels of the Sanctuary and Those Who Serve Therein הלכות כלי המקדש והעובדין בו