Activating the quest
Quest requirements: This quest can be completed at any moment of the game. I'd suggest completing it early on in the game, especially considering that it doesn't include any "real" fights, mainly focusing on puzzles.
Open the world map and head to Solitude (screen above). The city is located in the northern part of Skyrim and in case you weren't there it would be easiest to use a carriage (e.g. the one at Whiterun Stables).
During daytime, head to the eastern part of Solitude, to the Bard's College. There you should come across Dervenin (screen above), who upon being spoken to, will tell you that his master is trapped between world. Dervenin will send you to the Blue Palace in Solitude, specifically to the normally inaccessible Pelagius Wing and additionally give you the Pelagius's Hip Bone.
Getting to the Pelagius Wing
New main objective: Gain access to the Pelagius Wing of the Blue Palace
Head south-east and soon your should reach the Blue Palace entrance (screen above). If you had visited that place before, you can use the fact that it's visible on the world map and speed things up. In order to gain access to the Pelagius Wing, you will have to obtain one of the keys possessed by three people in the Palace. The mentioned keys unfortunately cannot be stolen, as they don't appear in the inventories of those characters. Instead, speak to a chosen one and encourage her to give you the key.
Erdi (screen above) won't be at first too eager to give you the Pelagius Wing Key, though she should change her mind if you tell her that Falk has sent you to check the area.
Falk Firebeard (screen above) won't be willing to give you the Pelagius Wing Key and the only way of making him change his mind is completing The Man Who Cried Wolf side quest which he can give you. After completing the quest, you would need to return to Falk and try again.
Una (screen above) won't be eager to give you Pelagius Wing Key at first, but she should change her mind if you mention that Falk has sent you to examine the area.
New main objective: Use the key to gain access to the Pelagius Wing
New main objective: Search for Dervenin's master in the Pelagius Wing
The door leading to the Pelagius Wing can be found in the south-west part of Blue Palace (screen above). Use the key obtained from one of the previously mentioned characters and start exploring the empty corridors of the Palace. Continue until you get automatically taken to a new location.
You will be taken to The Mind of a Madman, inside which you will have to solve some puzzles, counting only on yourself. The one behind the whole commotion is the Daedric Prince of Madness Sheogorath. Start off by listening to his conversation with Pelagius the Mad (screen above).
You will be able to speak to Sheogorath directly only after Pelagius gets dismissed (screen above). From the rather long conversation you will learn the you're inside the head of emperor Pelagius III and the only way of getting out is solving all the puzzles prepared by the Daedric Prince. The Wabbajack that you receive from Sheogorath will come in handy for that (you can't use your standard items here).