What is the evidence for stipulating that one should be in a state of purity before putting on the khuffs?
Question

One of the texts which prove it is permissible to wipe over the khuffs is the hadith of the Messenger of Allah (blessings and peace of Allah be upon him), which is: It was narrated that al-Mugheerah ibn Shu‘bah (may Allah be pleased with him) said: I was with the Prophet (blessings and peace of Allah be upon him) on a journey. I bent down to take off his khuffs and he said: “Leave them, for I put them on when my feet were clean.” Then he wiped over them. The scholars say that one of the conditions of it being permissible to wipe over the khuffs is that they should have been put on when one was in a state of purity, referring to wudu’, based on this hadith. I do not understand this, because in the text of the hadith it says that the Prophet (blessings and peace of Allah be upon him) put on the khuffs when his feet were clean, as he said. Does this refer to wudu’? Because his feet may have been clean without him having done wudu’, and he could have said, “Leave them, for I put them on when I was in a state of purity,” not “when my feet were clean.” I hope that you can give me an answer about this confusion. May Allah reward you with good.
Praise be to Allah.The majority of jurists stipulated that in order for wiping over the khuffs to be permissible, they must have been put on when one was in a state of purity. They based that on the hadith of al-Mugheerah ibn Shu‘bah (may Allah be pleased with him) who said: I was with the Prophet (blessings and peace of Allah be upon him) on a journey. I bent down to take off his khuffs and he said: “Leave them, for I put them on when my feet were clean.”  Narrated by al-Bukhari (206) and Muslim (274).
Dawud az-Zahiri (the literalist) was of the view that what is stipulated is that the feet should be clean only.
What supports the view of the majority is the report narrated by ‘Abd ar-Razzaaq in his Musannaf (793), Ibn Khuzaymah (193) and Ibn Hibban (1325) from Safwan ibn ‘Assal (may Allah be pleased with him), who said: We were with the army that the Messenger of Allah (blessings and peace of Allah be upon him) sent out. He ordered us to wipe over our khuffs, if we had put them on when in a state of purity, for three days when we were travelling, and for one night if we were not travelling, and not to take them off after defecating or urinating, and not to take them off except in the case of janabah. Classed as hasan by al-Albani and by Shu ‘ayb al-Arna’ut in Takhrij Ibn Hibban.
Al-Bayhaqi narrated it in as-Sunan al-Kubra (1/423) as follows: If we had put them on in a state of purity. Its isnad was classed as jayyid by an-Nawawi in al-Majmu‘ (1/512).
For more information, please see: at-Tibyan fi Tabwib wa Takhrij Bulugh al-Maram by Khalid al-Shalahi (2/47-51).
Ibn Khuzaymah commented on that by saying: I mentioned to al-Muzani the report narrated by ‘Abd al-Razzaq, and he said: Narrate that to our companions, for there is no stronger evidence for ash-Shafa‘i than that. End quote.
Al-Hafiz Ibn Hajar said: Even though the hadith of Safwan is sahih, it does not meet the conditions of al-Bukhari. But the hadith that is mentioned in al-Bukhari is in harmony with this hadith, which stipulates that one should be in a state of purity when putting them on.
Al-Muzani was referring to a difference of opinion regarding this matter. In brief, al-Shafa‘i and the majority of scholars understood the references to cleanliness as meaning taharah (purity) in the shar‘i, ritual sense, i.e., wudu’, whilst Dawud disagreed and said: If there was no impurity (najasah) on the person’s feet when he put on the khuffs, it is permissible to wipe over them."(Fath al-Bari  1/309).
Thus it becomes clear that the view of the majority is sound and their evidence is strong for stipulating that the khuffs should have been put on when in a state of purity.
And Allah knows best.