A king could also be a priest, just not a member of the Aaronic priesthood.
As Mawia has already stated, in pre-monarchic Israel and throughout the Levant, both father (as head of the household) and firstborn sons typically served as priests (e.g., Numbers 3:13). In addition, the king typically served as a priest for the entire nation (as with Melchizedek in Genesis 14).
Since according to the Mosaic Law, only the direct male line of Aaron could serve as Aaronic priests in the Tabernacle and Temple (Exodus 28:1, Numbers 3) undertaking sacrifices to God, and as the kings of Israel and Judah all came from the tribes of Judah, Benjamin, Ephraim, etc, they were disqualified from birth.
However, the royal Psalm 110 written by David indicates that God had promised that the Davidic king could also be a priest (v.4). There are several different ways to translate the ambiguous Hebrew verse:
- that the Davidic king is a priest forever "in the order of Melchizedek", i.e., in the same mannner that Melchizedek was a king-priest;
- that the psalm is actually being addressed to Melchizedek, the original king-priest, saying that Melchizedek will forever remain a priest;
- that the Davidic king is "a priest forever, a rightful king by My decree".
Now, if we go with the first or third interpretation, then the functions of the Davidic king, as a (Melchizedekite?) priest, are mostly unknown. We only know that the king was not allowed to personally make sacrifices to God (1 Samuel 13). David's behavior in 2 Samuel 6:14-15, wearing a linen ephod (priestly attire) and dancing in ecstasy before the Ark, may be another example of the king's priestly role in action.