Rabbi Yohanan in the Gemara quotes a passage in II Divrei Hayamim 29:16, which relates the story about King Hizkiyahu’s refurbishing of the Beit HaMikdash. According to the passage, the kohanim removed all of the impure things that they found in the Temple and passed them to the levi’im in the Temple court, who carried them out to the Kidron Valley. Although it appears that entering the Mikdash to clean it is limited to kohanim and levi’im, a baraita is brought to the contrary.
The Sages taught in a: It is permitted for everyone to enter the Sanctuary to build, to repair, or to remove impurity from inside. However, wherever possible, the mitzva is for these tasks to be performed by priests. If no priests are available, Levites enter; if no Levites are available, Israelites enter. In both cases, if they are ritually pure, yes, they may enter, but if they are impure, no, they may not enter the holy place.
Rav Kahana rules that kohanim are always preferable over non-kohanim, even if there are defects in the kohen or if he is tameh (ritually unclean). Rav Huna introduces Rav Kahana’s ruling with the comment that Rav Kahana – who was himself a kohen – always looks out for their interests and emphasizes their unique status in halakha. Rav Kahana cites the passage (Vayikra 21:23) which limits the participation of a kohen who is a ba’al mum – who has a physical blemish – in the Temple service, and interprets it to mean that he can, nevertheless, enter the Temple in order to do the work of an artisan in the Mikdash.
Far from being just a theoretical discussion, these rulings had practical implications throughout history. When Herod decided to refurbish the Second Temple, the large building project that took place outside the Temple itself was completed relatively quickly. Once work began on the inner parts of the Mikdash, the desire to employ only qualified kohanim slowed down the work severely, and the project dragged out over a period of years – some say even generations – until its completion.