At the conclusion of the Shivering Isles expansion, Sheogorath transforms into Jyggalag, the Daedric Prince of Order, in a dramatic reveal.
However, if you follow the dialogue carefully, Sheogorath explains that he and Jyggalag are actually two halves of the same being, cursed to alternate control of the realm. So the "twist" isn't a contradiction so much as the completion of that cycle, with the player helping Sheogorath retain his chaotic identity.
Some fans have pointed out apparent lore inconsistencies around which entity truly represents Order, but taken at face value, the ending is about restoring the balance between Order and Chaos by keeping Sheogorath in charge.