I feel that the Queen was probably not there from the beginning. She was probably a creation out of necessity for the development of the hive.
Evidence for this is the Voyager episode Unity, where the former drones re-initialize a cooperative, and they have no need for a Queen. But as the size of the collective grows, it makes sense for there to evolve a hierarchy.
Isn't that how it works in actual bee hives?
Nope. In bee hives (and ant nests and termite colonies, etc.) the Queen is first.
Also, the Queen, in spite of her name, doesn't actually dominate or control the hive, per se. She's just the only female that's allowed to reproduce.