At the end of Thor: The Dark World, Loki banished Odin to Earth and disguised himself as the All-Father so that he could rule Asgard.
Cut to the end of the movie, Asgard was destroyed, but Thor and his allies successfully evacuated its citizens, so one can only hope that Matt Damon’s character and his fellow performers made it out alive as well.
Because Thor was so busy with his Avengers duties and trying to solve the mystery of who was gathering the Infinity Stones together, the God of Thunder wasn’t spending that much time in his home realm, and thus didn’t learn what his deceptive brother had done until several years later in Thor: Ragnarok.
But upon defeating Surtur, returning to Asgard with the fire demon’s crown, coming across this play that made Loki out to be more of a hero then he actually was (something tells me it won’t be winning any Asgardian Tonys) and seeing how strange “Odin” was acting, he finally realized what Loki had done and forced him to reveal himself to the Asgardian population.