The gemara asks how they were able to heat up the mikvah of the kohein gadol with hot metal since by immersing it into the water it would harden the metal and would be metzareif it which is an issur on shabbos and yom kippur. Rav Bibi says that by the time they would immerse it in the water it wouldn't be that hot and would not be metzareif the metal. Abaye disagrees and says that even if it were hot that it could come to tziruf, it was permitted since it was a דבר שאינו מתכוין. The gemara challenges this by Abaye himself who seems to understand that the pasuk permitting cutting off tzaraas to do bris milah is necessary for R. Yehuda who holds that a דבר שאינו מתכוין is assur, implying that this is Abaye's opinion. The gemara answers that on a melacha d'oraysa it would be assur even if one was not mechavein, but tziruf is only d'rabonon. Meaning that since it is a דבר שאינו מתכוין on an issur d'rabonon, it is mutar. Tosafos explains that according to Rashi tziruf would only be d'oraysa on a kli, but on a piece of metal would just be d'rabonon.
Tosafos cites the R"i who learns the gemara differently. Abaye was only suggesting that a davar she'eino miskavein was not assur on a torah level, it was only assur m'drabonon. The gemara challenges this from mila where we need a pasuk to change the default of a דבר שאינו מתכוין אסור מן התורה, and answers that since by shabbos there is an additional requirement of מלאכת מחשבת, even R. Yehuda would admit that a דבר שאינו מתכוין by shabbos would only be drabonon. Since it is only d'rabonon, we are meikel in the beis hamikdash for the need of the avoda. Based on Tosafos we can prove that R. Yehuda only considers a דבר שאינו מתכוין to be an issur d'oraysa by other issurim, but not by Shabbos.
According to Tosafos it is easier to understand why the mishna only permitted this when the kohen was old or an istanis. If the kohein could bear the cold water it would be assur since it would not be necessary in the running of the beis hamikdash and would not be a need of the avoda. According to Rashi it should have even been permitted for a young kohein.
R. Akiva Eiger cites the pri chadash to support Tosafos. If it were permitted even outside of the mikdash, why is it only mentioned as being done by the mikva that was בבית הפרוה and build in kodesh, not in the first mikvah which was built בחול. According to Tosafos it is understandable that since we are relying on the concept of אין שבות במקדש, it can only apply within the area that was kodesh and could not be done by the first mikvah that was built b'chol. To answer for Rashi we need to say that one tevila he would be able to handle the cold, and this was only a need for the mikvah where he would have to immerse 4 times.