From Think Progress:
The Supreme Court explained more than a century ago, in its 1898 decision in United States v. Wong Kim Ark, why the Fourteenth Amendment contains a limited exemption for people not “subject to the jurisdiction” of the United States.
The real object of the fourteenth amendment of the constitution, in qualifying the words ‘all persons born in the United States’ by the addition ‘and subject to the jurisdiction thereof,’ would appear to have been to exclude, by the fewest and fittest words (besides children of members of the Indian tribes, standing in a peculiar relation to the national government, unknown to the common law), the two classes of cases,- children born of alien enemies in hostile occupation, and children of diplomatic representatives of a foreign state,-both of which, as has already been shown, by the law of England and by our own law, from the time of the first settlement of the English colonies in America, had been recognized exceptions to the fundamental rule of citizenship by birth within the country.
When the Fourteenth Amendment was ratified, in other words, there were a few limited classes of children who were born with the United States’ territory but not subject to its laws. They included some Native Americans whose tribes existed as separate sovereign nations within the United States, but also children of foreign diplomats (who enjoy diplomatic immunity from the law of the nation they are visiting), and any children born to a hostile invading army.