Prior to the events of the game, plague and famine ravaged the land of Hyrule. The king was suspicious that it may be Ganon behind all of it, but the seal that confined the evil entity during the Imprisoning War was still intact. The King of Hyrule felt hopeless, when all of a sudden a wizard named Agahnim appeared and ended the plague with his magic. The king was so shocked and pleased with this service, that he blindly made Agahnim his chief adviser and declared him to be the second coming of the Seven Wise Men.
When Agahnim gained the King of Hyrule's full trust, however, he betrayed and murdered him (implied in the opening of A Link to the Past, which features what appears to be the King of Hyrule's skeleton), and seized the throne of Hyrule for himself. Posing as the King of Hyrule, Agahnim uses the king's name to enact false decrees, such as the order for Link's arrest and signs offering rewards for whoever finds the descendants of the Seven Wise Men. After Link slays Ganon in the final battle, all the wrongs committed by Agahnim are undone and the King of Hyrule is given back the throne. During the ending credits, he can be seen standing outside Hyrule Castle with Princess Zelda and the Six Maidens.