Upon discovering a certain, crucial little secret about Cedric (Peter O'Toole), as well as the details of the conspiracy Lord Graves (John Hurt) had elaborated to force him off the Throne, Ralph (John Goodman) calls in an assembly, in which he announces his abdication. At the same time, he lets everyone know about a cooperation treaty signed between England and the Kingdom of Zambeze, to manufacture cars.
Lord Graves's scheme is publicly exposed, and Ralph has him arrested by means of the Treason Act of 1702 by King William III. And, to top things off, he appoints Cedric as the new King of England, since he was also a member of the Windham family -THAT WAS THE SECRET-.
Since Ralph still loved Miranda (Camille Coduri), he reconciles with her. Upon becoming the new King, Cedric appoints Ralph as the Duke of Earl -he covers his ears at the ceremony to prevent having them chopped off, as he accidentally did to some other noble, earlier!
He and Miranda get married, and the movie ends with him, doing his music from some castle in the countryside, performing "The Duke of Earl", while Miranda and their son watch him.
Thanks Dr Mat!