Long before the physical structure of the Temple was built, its organizational system and the specific roles of the Levites were carefully planned. King David and Samuel the Prophet sat together to shape the vision for the Temple's layout and its daily routines [רלב״ג, ביאור שטיינזלץ]. Samuel, known as the seer because he received prophetic visions [מצודת ציון, ביאור שטיינזלץ], worked closely with David to establish this order. Some suggest that this joint planning took place years earlier, when David was fleeing from King Saul and hiding with Samuel. During that time in exile, they designed the system together, and once David ascended to the throne, he put their plan into action [רלב״ג].
As part of this master plan, a total of two hundred and twelve chosen Levites were appointed as gatekeepers to guard the entrances of the Temple [מצודת ציון, ביאור שטיינזלץ]. While other biblical records, such as those in Ezra and Nehemiah, mention a lower number of guards, commentators explain that those accounts only counted the guards who were physically present on the Temple Mount at a given time. The count of two hundred and twelve represents the total roster of appointed gatekeepers [מצודת דוד, רלב״ג]. These Levites did not all serve at the same time. Instead, they were divided into weekly shifts that rotated every seven days [רד״ק]. This division created a daily workforce of about thirty gatekeepers. Twenty-four served as regular guards at the entrances, while the remaining six were assigned to special duties, taking charge of the chambers, the treasuries, the sacred vessels, and the showbread [מלבי״ם].
To ensure the system ran smoothly, the gatekeepers lived in villages and courtyards surrounding Jerusalem. This allowed them to travel quickly and easily to the Temple for their scheduled shifts [מצודת דוד, רלב״ג]. These settlements were the very same cities that had been given to the Levites generations earlier, during the time of Joshua [רד״ק]. To maintain order, each family possessed a detailed genealogy book that officially linked them to their specific city of residence and their assigned shift [מצודת דוד, רד״ק, מלבי״ם].
The foundation of this system was rooted in a concept of lasting stability. The primary approach among commentators is that the establishment of this order was meant to be permanent. David and Samuel fixed the number of gatekeepers as a permanent standard for all future generations, ensuring the ranks would never be reduced. Another perspective suggests a more literal understanding of faithfulness. According to this view, the system was successfully established due to the deep loyalty David and Samuel had toward God, or it served as a direct instruction to the Levites, reminding them to perform their sacred duties with absolute faithfulness [רלב״ג, ביאור שטיינזלץ].