Hagia Sophia is a historical heritage built during the reign of Roman Emperor Justinian in 537 AD and remained a Christian church for 900 years, then Sultan Mehmet (The Conqueror) converted it into a mosque after the conquest of Constantinople in 1453 AD. It remained so for 500 years, but after the fall of the Ottoman Empire, the mosque was turned into a museum by the order of Ata Turk Mustafa Kemal Pasha.
First we have to know that the decision of converting church into a mosque by Sultan Mehmed (The Conqueror) was right or wrong.
At the time of Prophet Muhammad (pbuh) and his Companions, Muslims achieved many victories, but they had never destroyed the Worship places of Non-Muslim nor converted them into a Mosques, rather than that Islam teaches us to give them full peace and protect their worship places!
And in this regard the incident of Hazrat Umar (r.a) is famous, when he went to The Jerusalem after the conquest on the call of there Ruler to get the keys of Jerusalem and and at the time of prayer he was in the church, so the Bishop (Priest) said him to pray there but Hazrat Omer (R.A) denied him by saying that I'm afraid if I pray here then The Muslims would later forcely occupy this place by claiming that it is the place where the Muslim Caliph prayed. After that he prayed at the place from where the Prophet (peace be upon him) had ascended to heaven for his (Night Journey).
The Ottoman Sultan Mehmed (The Conqueror) instituted many measures which was definitely against The Islam, among them one, was to converted the church into a mosque, and for this reason there was always had a war zone situation between Muslims and Christians!
And then when Mustafa Kemal Pasha gave "Hagia Sophia" the status of a museum, by which the relations between Muslims and Christians were improved, but turning a place of worship into a museum was also a wrong decision, because in the Mosque we worship Allah (swt). and Kamal Ataturk made it a Tourist resort only for his own political gain.
But things went on like this, and the question was always there whether to keep Hagia Sofia as the museum or to give it back the status of a mosque, and finally the Turkish government restored Hagia Sofia as a mosque.
But it also seems like the Turkish government has their political interest, because when Turkish President Recep Tayyip Erdogan began his political career, he was a staunch supporter of making "Hagia Sofia" a mosque, but as his political position grew stronger. Eventually, he softened on the issue, even few years ago he said that those who wanted to convert "Hagia Sofia" into a mosque again, first they should have to fill the Sultan Ahmed Mosque which is next to "Hagia Sophia" and the rest of Turkey's mosques from the Prostraters.
When a Political Persons has fear of losing his popularity, so these political figures take advantage of the weaknesses of the people, and Tayyip Erdogan did so, in order to further strengthen himself politically he used Islam and resorted to Muslims emotion.
But the incident has caused a stir in Europe as Muslims have once again been treating Christians unfairly.
In my opinion, the Turkish government should not have raised this issue, and if they had to make a decision, they should have made on which both Muslims and Christians would have agreed. And idea of converting "Hagia Sophia" into a Mosque should have been settled, because there's no shortage of Mosques for Muslims to pray and no shortage of Churches for Christians, and anything that causes dissension among the people should be end there.