To appoint a king over them, as it is written (Deuteronomy 17:15): "You shall surely set a king over yourself." And to build the House of Choice, as it is written (Exodus 25:8): "And they shall make Me a sanctuary." And to blot out the remembrance of Amalek, as it is said: "You shall blot out the remembrance of Amalek."
Three Commands for the Land - King, Temple, Blotting Out Amalek
Midrash Tanchuma Buber, Ki Teitzei 17:2
למנות עליהם מלך, דכתיב שום תשים עליך מלך (שם יז טו), ולבנות בית הבחירה, דכתיב ועשו לי מקדש (שמות כה ח), ולמחות את זכר עמלק, שנאמר תמחה את זכר עמלק.