Why are non-Muslims not allowed in Makkah and Madinah? What would happen if they enter these places?
This is an administrative decision. This practice arose to safeguard the purified sanctuary of Makkah. The Kabah was created by Abraham as a place of worship of the One God. At the time there was no such restriction on the entry of non-Muslims to the Kabah. It had free entry for all for over 1,300 years. But the idol-worshiping visitors started placing their idols in the Kabah, and the number of idols reached 360. After this experience, the above restriction was imposed at the time of Prophet Muhammad.
There are many big and popular mosques around the world, such as the Blue Mosque in Turkey and Sheikh Zayed Mosque in Abu Dhabi, which are open to tourists and visitors and to non-Muslims. If the visitors start placing idols inside these mosques which were built for a certain religious practice, it is but natural for the government, or the authority of the mosque, to put in place a check for such visitors in the future.
In today’s advanced security era, it may not be possible that the previous experience pertaining to the Kabah be repeated. Therefore, in principle it may be argued that the Saudi Arabian government can lift the ban on the visit of non-Muslims. But pragmatically this may not seem as an option because once a practice becomes an established tradition over centuries, changing it becomes a very complicated matter. The current focus of the government is to use its resources to manage the annual pilgrimage, an event for which Muslims around the world are on waiting-list. Most people get only one opportunity to perform the pilgrimage in their lifetime.