* First off, allegiance is pledged to the flag, with "to the Republic" almost an afterthought: following an "and" and never mentioned as a variant title for the exercise (we don't talk about "Pledging Allegiance to the Republic").
* The Republic in The Pledge is defined as "one nation," as opposed to a confederation of states undoubtedly, but also as a conflation of nation and republic. The U.S. isn't a nation in the same sense that Japan is a nation, or in the sense of "nations" in the joke in the song from HMS Pinafore: "But, in spite of all temptations / To belong to other nations / He remains an Englishman."
In everyday usage "nation" is still often expanded to "Christian nation," and at one time that was "White, Christian nation" (and Catholics, in such usages, weren't Christians, and Jews weren't White). And the nominally-Christian racists had and have a point: traditional nations were supposed to be united by "blood" and faith or "blood and soil" (Blut und Boden). I am a citizen of and have sworn my loyalty to the American Republic established by the U.S. Constitution; I don't belong to some hypothetical American nation.
* Between "liberty for all" on U.S. territory and a sense of security for "natural born" U.S. citizens, most Americans would probably go for security.
If we want a patriotic exercise, maybe reciting this: "I pledge allegiance to the Constitution of the United States and the Federal Republic established thereby, and will strive to achieve domestic tranquility, provide for the common defense, promote the general welfare, and secure the blessings of liberty for us today and for future generations."