Abu Hurairah (RA) reported Allah's Messenger (ﷺ) as saying: A time will come for the people (of Madinah) when a man will invite his cousin and any other near relation: Come (and settle) at (a place) where living is cheap, come to where there is plenty, but Madinah will be better for them; would they know it! By Him in Whose Hand is my life, none amongst them would go out (of the city) with a dislike for it, but Allah would make his successor in it someone better than he. Behold. Madinah is like a furnace which eliminates from it the impurities. And the Last Hour will not come until Madinah banishes its evils just as a furnace eliminates the impurities of iron.
Abu Hurairah (RA) reported Allah's Messenger (ﷺ) as saying: I have been commanded (to migrate) to a town (Madinah) which would overpower other towns. They (the people) call it Yathrib; its correct name is (in fact) Madinah. It eliminates (bad) people just as a furnace removes the alloy of iron.
This hadith has been narrated by Yahya bin Sa'id with the same chain of transmitters (and the words are): "Just as a furnace removes impurity," but no mention is made of iron.
Jabir bin'Abdullah (RA) reported that a desert Arab swore allegiance to Allah's Messenger (ﷺ) . He suffered from a severe fever in Madinah (and) so he came to Allah's Messenger (ﷺ) saying: Muhammad, cancel my oath of allegiance, but Allah's Messenger (ﷺ) refused it. He again came and said: Cancel my oath of allegiance, but he (the Holy Prophet) refused it. He again came to him and said: Cancel my oath of allegiance, but he refused. The desert Arab, however, went away (cancelling the allegiance himself); thereupon Allah's Messenger (ﷺ) said: Madinah is like a furnace which drives away its impurity and purifies what is good.
Zaid bin Thabit reported Allah's Apostle (ﷺ) as saying: It is Taiba, thereby meaning Madinah. It drives away impurity just as fire removes the impurity of silver.