Wa `alaykum as-salamu wa rahmatullahi wa barakatuh.
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.
Hijrah was not something special for Prophet Muhammad (peace and blessings be upon him). Rather, some of Allah's prophets emigrated before Prophet Muhammad (peace and blessings be upon him). Yet, the Hijrah of Prophet Muhammad (peace and blessings be upon him) differed from those of other prophets because it was not intended as a flight from torture but as the beginning of the Islamic state.
Responding to the question, the eminent Muslim scholar, Sheikh Yusuf al-Qaradawi, states the following:
Most of Allah's messengers, if not all, emigrated. however, their emigrations differed from that of Prophet Muhammad (peace and blessings be upon him). For example, Prophet Ibrahim (peace and blessing be upon him) emigrated, as related in the Qur'an:
"And lot believed him, and said: Lo! I am a fugitive unto my Lord. Lo! He, only He, is the Mighty, the Wise" (The Holy Quran, 29: 26).
In another verse, He Almighty says:
"And he said: Lo! I am going unto my Lord who will guide me" (The Holy Quran, 37: 99).
So, Prophet Ibrahim (peace and blessings be upon him) migrated from place to place till he settled at a town in Palestine, where he was then buried. That town, Al-Khalil Ibrahim, is now named after him.
Prophet Musa (peace and blessings be upon him) also emigrated before he was assigned with the Divine mission. He fled from Egypt after he had mistakenly killed an Egyptian. He sought Allah's forgiveness for that, and a man advised him to get out of Egypt in order to escape people’s revenge. Allah Almighty says:
"And a man came from the uttermost part of the city, running. He said: O Moses! Lo! The chiefs take counsel against thee to slay thee; therefore escape. Lo! I am of those who give thee good advice. So he escaped from thence, fearing, vigilant. He said: My Lord! Deliver me from the wrongdoing folk" (The Holy Quran, 28: 20-21).
Then Prophet Musa (peace and blessings be upon him) went to a country called Madyan, where he married the daughter of a righteous old man (Prophet Shuaib, peace be upon him) and stayed with him for ten years. Throughout that period, Musa had no Divine mission. He lived as a righteous man, a good husband, and a generous son-in-law; however, he had no prominent role to perform.
That is to say, Prophet Musa (peace and blessings be upon him) emigrated for fear of revenge. He said, as related in the Qur'an:
"Then I fled from you when I feared you, and my Lord vouchsafed me a command and appointed me (of the number) of those sent (by him)" (The Holy Quran, 42: 21).
On the other hand, the Hijrah of Prophet Muhammad (peace and blessings be upon him) was not only to escape temptation and torture of his people. It was the starting point to establish the Muslim ummah, a new Muslim community based on Islam, the universal Divine message that calls for morality and human rights. That was the very purpose of Prophet Muhammad's Hijrah to Madinah, and he (peace and blessings be upon him) performed his role as best as possible. He put the foundation of a sound Muslim community and established the best ummah ever created.