It is narrated from Sayyiduna Zaid bin Thabit (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) took off his clothes to enter into Ihram and performed ghusl (ritual bath).
Brief Explanation
(Commentary on Hadith 1831)
Imam Tirmidhi rahimahullah said: In light of this hadith, some scholars have considered it recommended (mustahabb) to perform ritual bath (ghusl) at the time of donning the ihram. This is also the opinion of Imam Shafi’i rahimahullah.
It is recommended (mustahabb), not obligatory, to perform ritual bath (ghusl) at the time of ihram. The correct view is that the Messenger of Allah sallallahu alayhi wa sallam left his house after performing ritual bath (ghusl), but began the ihram and talbiyah upon reaching the miqat.
(And Allah knows best)