The Emperor's New Clothes is a great story with a lot of complexity around the values and motivations of the people.
- emperor (uncaring/materialistic)
- officials (questioning/self-doubt/faithful to a fault)
- citizens (concerned with neighbors' opinion until safe)
- weavers (swindlers)
- children (innocent)
I always had a negative view of the emperor. The officials, even more so, because they should have been his trusted advisors. The real answer, as it relates to the emperor, I think comes down to the last sentence.
The translation from the The Hans Christian Andersen Centre linked by @Meredith uses the word "shivered" and states "he suspected they were right"
However, the Project Gutenberg translation uses the word "writhed" and states "for he knew it was true." (HTML version)
The Emperor writhed, for he knew it was true, but he thought 'the procession must go on now,' so held himself stiffer than ever, and the chamberlains held up the invisible train.
I don't know the Danish language, but it's odd that the words the translators each chose differ so much in meaning. Just like @Meredith
So let's say we look the other way on that small fact about whether he knew or just suspected. The real question is WHY did the Emperor think
the procession must go on now.
Here is my view on the ending: As a leader he suspected he had been fooled, but he wan't sure until the kid said something (so not the brightest guy).
However, sometimes a leader has to lead. If all of his officials and subjects sat around and thought about how bad things were, or how hard the tasks ahead were going to be, things might never improve. Everyone has doubts deep down. We want to be inspired by leaders, and we expect those leaders to show confidence. We also want leaders to be good people, intelligent, caring, and honest.
So the emperor decided he must continue to lead. Let's hope he figures out the rest of it.