The Quran says: 'O you who believe, the idolaters are unclean, so let them not approach the Sacred Mosque after this year.' In the ninth year after the Hijrah, Abu Bakr, whom the Prophet Muhammad ﷺ had appointed to lead that Hajj, sent announcers to Mina to declare that after that year no idolater would perform Hajj and nobody would circle the House naked. The 'impurity' here is understood by most scholars as the spiritual impurity of idolatry, not as a statement that non-Muslims are dirty people.
Scholars differ on how far the verse extends. It names the idolaters, and the Maliki, Shafi'i and Hanbali schools apply it to all non-Muslims entering the Sacred Mosque; they also extend it to the whole sanctuary (haram) of Mecca, which is the rule in Saudi Arabia today. The Hanafi school held that it forbids non-Muslims only from performing Hajj or Umrah, and allowed them to enter for other reasons. This is a real difference of opinion; the present rule on the ground follows the stricter view.
The reason given is that Mecca is a sanctuary: the Quran says Allah made it a safe haven and a sacred place, where Abraham's House stands, so that people may worship Him alone and be safe. It is a place of worship, not a tourist site, and many religions limit access to some of their most sacred places. If you are not Muslim, you can enter almost every mosque in the world; you can read the Quran; and you can always choose to become Muslim, and then perform Hajj or Umrah like anyone else.