It is so tempting to give a desperately simple answer here: Princess Pea walks up the stairs and out of the dungeon because Roscuro, the rat, leads her out.
And so, here are the words that the princess spoke to her enemy.
She said, "Roscuro, would you like some soup? ... I promise you, " said the princess, "that if you lead us out of here, I will get Cook to make you some soup. And you can eat it in the banquet hall." ...
"Truly. I promise." ...
The princess bent down before [Despereaux]. "You are my knight," she said to him, "with a shining needle. And I am so glad you found me. Let's go upstairs. Let's eat some soup."
And, reader, they did.
However, let's look at the complexity of the issue:
- Roscuro freely offers to lead Princess Pea out of the dungeon because she offers him soup.
- The Princess Pea offers Roscuro soup due to her "empathy" after hearing his epiphany about not wanting to do horrible things. "All I wanted was some light. That is why I brougth the princess here, really, just for some beauty, ... some light of my own."
- Roscuro only has an epiphany because he smells soup on Despereaux's whiskers.
- Despereaux's whiskers have the smell of soup because Cook offers Despereaux soup before he embarks on his quest.
- Cook offers Despereaux soup, usually against her better judgement, because she has her own epiphany that soup needs to comfort another in order to be truly enjoyed. "Soup needs another mouth to taste it. Another mouth to be warmed by it."
- Cook only has her ephiphany because she is illegally cooking soup at midnight to comfort herself because the princess has been kidnapped.
- The Princess Pea has been kidnapped because of Roscuro's revenge.
- Roscuro wants revenge on the Princess Pea because of her look of contempt after Roscuro mistakenly falls in the Queens soup and kills her (through a heart attack).
- Roscuro only falls in the soup because he is getting a birds-eye view of the party.
- Roscuro only wants a birds-eye view of the party because he has fallen in love with light, ... the same kind of light that Despereaux loves as well.
So, in the words of Miggery Sow, I must say, "Gor!" that's a long list! Ha! Therefore, in summary, I must say that the Princess Pea gets out of the dungeon due to a masterful web of plot points delicately, intricately, and exquisitely created by dear Kate DiCamillo.