[Commentary]
Imam al-Nawawi, may Allah have mercy on him, cites this hadith in Riyad al-Salihin, in the chapter on visiting the sick and accompanying the funeral, on the authority of Abu Hurayrah. In it the Prophet ﷺ relates that Allah will say on the Day of Resurrection: “O son of Adam, I was ill and you did not visit Me.” He will reply, “How could I visit You when You are the Lord of all creation?”—that is, You are in no need of me such that I could visit You. Allah will say, “Did you not know that My servant So-and-so was ill and you did not visit him? Had you visited him, you would have found Me with him.”
There is no theological problem with Allah’s words, “I was ill,” for it is impossible for Allah Most High to experience illness; infirmity is a defect, and Allah is exalted above every imperfection. As He says: “Glorified be your Lord, the Lord of Might, far above what they attribute to Him” (Q 37:180). The illness referred to here is the illness of one of His righteous servants. They are Allah’s chosen allies (awliyaʾ).
For this reason the sound sacred hadith also states: “Whoever shows enmity to a friend of Mine, I have declared war upon him,” meaning that whoever opposes Allah’s allies is, in reality, at war with Allah Himself—even if he imagines he has not opposed Allah directly, he has nonetheless opposed and fought His allies. Likewise, when one of Allah’s righteous servants falls ill, Allah, Exalted is He, is with him.