America has always had a contradiction at it's heart: It purports to represent high minded ideas about freedom, egalitarianism, peace, democracy, secular enlightenment ideals, etc... while simultaneously being none of those things for most of it's history. A country built on genocide and slavery, a government that excluded nearly everyone from participating in it, extreme inequality, a war every few years, laws based on religious sentiments of the majority, etc...
That the story it tells itself is so at odds with it's actual identity is a testament to the power of propaganda and self-delusion. I think part of how people try to resolve this contradiction is by refocusing the story to be about steady progress: We may not have always lived up to our ideals, but that was in the past, we learned from them, and got better, as they ignore the problems of today and even actively resist changes that they would applaud if they read it in a history book or saw it in a documentary.
It's not wholly unique in this kind of narrative self-delusion, but I think America's relative lack of longer term history and ethnic identity makes the story a more central part of it's identity. The pledge is one part of this.