Organizing the priesthood for the future Temple required addressing historical and demographic changes within the priestly families. Originally, during the era of the Tabernacle at Shiloh, the priestly duties were divided equally into sixteen work shifts, with eight families from the descendants of Eleazar and eight from the descendants of Ithamar [רש״י, מלבי״ם]. Over time, however, a major shift occurred. During a census of the priests conducted by King David [ביאור שטיינזלץ], it became clear that the men from the line of Eleazar who were fit and qualified for Temple service greatly outnumbered those from the line of Ithamar [מצודת דוד, ביאור שטיינזלץ].
To account for this gap in numbers, King David restructured the work schedule. He took each of the original shifts belonging to Eleazar's family and split them in half, resulting in sixteen distinct shifts for them alone. Meanwhile, the family of Ithamar was left in its original structure of exactly eight shifts [רש״י, מלבי״ם, מצודת דוד]. This reorganization established a permanent system of twenty-four priestly shifts in total. This specific number offered a practical solution for the yearly calendar. Once the festival weeks are subtracted—periods when all the priests work together to handle the majority of Temple duties—twenty-four shifts provide complete coverage for the remainder of the year. This setup ensures that every shift comes to serve in the Temple exactly twice a year [ביאור שטיינזלץ].