Pledging allegiance to the things that protect and serve you. Support for something larger than yourself. The American ideals in the constitution and on the statue of liberty, even if you don't feel others support them as much as they should.
The USA is a tremendous country that has done more to build protections for people into its law than almost anywhere else. You should see this and support it even if there are problems. America pledges equality and it's actually available. There's a reason the entirely of South America would move to the USA today, and it's a flattering reason if you'd look at it.
> It was still said during a time of complete racial segregation.
No, that never happened. Even during slavery, only some states practiced it and it was distasteful elsewhere, and even in those states it wasn't universal. Small help to a slave, sure, but your representation isn't fair.
> Did the practically unchanged pledge teach children about the morality and values of that?
Of the country that fought a hard war to end slavery, and is trying for equality? I dunno, you don't seem to have heard that message.
> Or domestic internment camps during WW2?
Meh, war is tough. When you're shooting some people it seems less bad to merely imprison some. Find a solution for the war itself and then let's talk about the imprisonment which were practiced to prevent more killing. Also, Canada did worse in its internments. More theft from the victims, and even worse scapegoating.
> What about during the Vietnam war?
What about? It was a badly chosen war that was guaranteed to go past the initial semi-principled stand into a huge quagmire of a proxy war. Dumb idea and bad. But are mistakes forever damning?
> What deeper nuanced meaning am I missing where it balances "freedom and liberty for all" with the massive expansion of the post-9/11 surveilance state?
So, like the Vietnam war, it's a mistake. But fight to save what you've got rather than equating it to the worst dictatorships. It's also a forgivable thing though, to overreact to murder. It took the UK and Ireland a long time to trust each other after the troubles.
You should be proud to be American. Your country at least tries to right wrongs.