"And you [Aaron] and your sons with you, before the Tent of Testimony"—Numbers 18:2.

We are commanded to station guards in and around the Temple, and that these guards patrol the Temple all night. This honor guard is a way of demonstrating respect for the Temple, exalting and glorifying it. As the Midrash says, "One can not compare a palace that has guards to a palace that does not."

The priests guard the Temple from within and the Levites guard and patrol it from the outside.