There's a point in "Yertle the Turtle" when it looks like Yertle's rule will never end. He's nice and secure up there at the top of the stack, he hasn't shown any inkling of changed emotion toward his fellow turtles, and "There's nothing, no, NOTHING, that's higher than [him]! (74).
But then on the very next page, there is something higher than him, something that kids will recognize instantly as being completely untoppable: the moon. This is just the kind of thing that really makes a dictator mad, as they like to be better than everyone else, and they like to be in control. But even the most brilliantly evil dictators can't be in control of everything. In fact, reaching for those things they can't control is generally what brings 'em down.
Yertle can shout at the moon and stack turtles all he wants. But eventually something will break, and Yertle will return to being just the little insignificant turtle he really is. That's why the moon is there: to symbolize everything over which Yertle exerts no control, and to break him at his faults.