Answer
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
When the Prophet (peace be upon him) was in the city of Mecca, he said that “I saw in a dream that Allah would command me to migrate to a city full of date palm trees.” He said “When I saw this dream, I thought it was Yamamah or another city known as Hajar until Allah commanded me to migrate to the city known as Yathrib, Al-Madinah.
When the Prophet was in al-Israa and al-Mi`raj, he said that “As I was passing and going on my way to Jerusalem, I saw this city that Allah had commanded me that I would migrate to.”
When he migrated to the city, the city was known as Yathrib and it has a negative meaning and a negative connotation to the extent that it was known as a diseased city, a disease full of Malaria and other sicknesses to the extent that people called it Yathrib which meant something that is cursed.
And that is why the Prophet wanted to change its name because many people had an ill feeling when they came to the city that they would get sick and some even passed away. The Prophet’s own father Abdullah and his mother Aminah passed away because of this sickness that was in this particular City.
And the Prophet always had a habit to change names that were negative or had bad connotations to that which were beautiful and had beautiful connotations and descriptions as well. This is why the Prophet said Allah commanded that its name be changed to Al-Madinah, Taybah and Taba, the pure, the beautiful, and the illuminated city of the Prophet.
Watch this video by Sheikh Hasib Noor to learn more:
Source: FaithIQ
Almighty Allah knows best.