Obviously the horses weren't the brains behind the operation. They were used to add physical strength to the effort of... putting Humpty Dumpty... back together... who I definitely remember as an egg but am just now realising was only illustrated that way and never actually referred to as an egg in the text of the rhyme itself...
Anyway they probably pulled carts of equipment or something idk how you put an egg back together. Or a human for that matter.
That would explain the horses. You got me interested enough to look into it, and the origin isn't clear. The cannon is one of the theories, it may also have been a riddle to which the answer was that Humpty was an egg.
I like the idea that it's a riddle containing a message that all the king's horses and men can't even put an egg back together. That no matter how much power and influence you have some things cannot be done; we are all mortal.
That message may have been dangerous to say out loud, but less so if you cloak it in rhyme and riddle.