I was idly thinking of introducing it earlier in order to foreshadow (and set up) better, and that maybe there should be a story to explain why the fairy tale kingdom has it -- a story where a prince married the princess of the next land maybe -- but no, I would use the Russian variant of the Three Little Birds and have the queen hide out there. (It's built by magic.)
But then I remembered there are two castles in the mountains, within sight of each other.
Probably a prince marrying the princess of a neighboring kingdom for that. After all, it's better than the Italian fairy tale where two kings can gibe at each other from the windows of their castles like two housewives hanging out laundry in the neighboring tenement buildings.