Starting a question with "Why on Earth...?" or "How on Earth...?" shows that you feel totally surprised by the thing that you're asking about. For example:
How on Earth did you get up there?
This is something you can ask someone who's standing on the roof of a house unexpectedly.
What on Earth are you talking about?
Ask this when someone says something really confusing.