Too bad for the Kingdom of Didd. Their King, King Derwin, is not too bright a fellow.
When he sees that Bartholomew Cubbins has not removed his hat for the royal procession, he drops everything, has the boy arrested, and then calls his court to try to resolve the situation. Never mind that the hat appears to be super-magical; Derwin just cannot stand the fact that a hat has not been removed in his presence per the rules.
King Derwin is a fool to be true, but he's also more than that. He's a fool with authority, and that's not a good person to have mad at you.
The authority comes with being King, but the foolishness comes with what he's willing to do with that authority. To get Bartholomew's hat off, he summons a hat maker, three wise men, an executioner, a bow man to shoot it off, and nine magicians to charm the hat away. Put all his other Kingly duties on hold; he's got a hat problem to deal with.
Worse, this folly goes right over his Kingly head. He even asks, "'Sir Alaric, what do you make of all this nonsense?'" and is completely oblivious to the irony of that question. Yeah, it is all nonsense, but the nonsense isn't the fact that Bartholomew can't remove his hat. The nonsense is how much trouble the King will go to enforce such silly rule.
The bright side? Well, when Wilfred steps out of line and tries to murder Bartholomew against the King's wishes, Derwin goes all "spare the rod spoil the child" on the Duke's pampered behind. While giving Wilfred a royal spanking, Derwin says "'that Grand Dukes never talk back to their King'" (138). It's the sole instance in the book where the King's authority helps another person toward a positive end.
(Although we should note that it's the talking back that's the issue and not the attempted murder. So, yeah, it's not like Derwin has learned his lesson. Things just happened to come up Bartholomew's way that time.)
In a way, King Derwin is a double warning: one for both parents and children. For the children, he's a warning that all authority figures aren't wise or just, and they certainly don't have your best interests at heart, necessarily. In other words, be wary of rules and authority, be it parental, social, or class-based.
As for the parents, if we're not careful, we can end up just like Derwin, and our authority can make us do crazy things, especially when trying to enforce it to the exclusion of reason and thought. It's like the book is asking us, at the very least, to make sure the rules we're enforcing have a purpose other than making us feel "mighty important" and Kingly (3).
Unfortunately, King Derwin, seeing as he's the King, doesn't have to learn the moral of the story despite being in it. Instead, he gets everything he wants and more. Bartholomew removes his hat in his presence and sells him a fancy new ruby-encrusted, plumage-laden hat to wear. What can we say? It's good to be the King.