UK law: What’s the legal status of Buckingham Palace relative to St James’s?

He doesn’t have to justify it to begin with, but the opposition could raise it during Question Time if they wish to, and then he’d be expected to provide an answer. It’s not as if some court of law would intervene to stop the PM from doing this; the question is rather whether, in the eyes of public opinion, the PM has stayed within the limits of his office. And if he can make a plausible case that there was some political rationale behind his advice to the King, that would likely be accepted (although people might, of course, still take a different political view on the matter).

And as to why QE2 liked wearing hats: I have heard the theory that she did it for better visibility when she appeared in or before a crowd of people. She was a rather short person, so spectators at a distance might have a hard time spotting her. That was, allegedly, also the reason for her preference for bright colours.

Yes. Even if it were kept quiet, the Palace is apparently leaky like a sieve, and the tabloids would very soon have a good retelling of the conversaion… “Queen Camilla told her hat maker that due to…”

So does a PM really want to be run out of office when the opposition starts yelling during the next electon “He’s more worried about the Queen’s hats than unemployment and inflation…”?

I believe it’s a common theme in politics “choose your battles”.

IIRC there were plenty of pics of Prince Phillip wearing not just a hat but a full uniform.

Whatever a PM does or says is open to question, by virtue of the position. That’s what they’re there for. (Though in practice, I suspect if it were a potential controversy around the monarch, the PM would have prepared the ground through behind the scenes consultations with the opposition parties in Parliament, to try to come to an agreed view on whatever it might be before going public).

I’m not sure it even needs much of an explanation. Most of the royal women wear hats because because there’s an expectation that they will dress formally, and in the UK that often means wearing a hat, much like British women routinely wear hats to weddings and horse racing festivals.

The younger royals are getting a little less formal in the hat wearing, but they still trot them out on occasion.

I have read that the Queen wore bright colours so that she stood out.