POE: Phrases of Excitement.
An utterance of great surprise, an exclamation of joy, awe, or fright.
'Heavens to Murgatroyd' is American in origin and dates from the mid-20th century. The expression was popularized by the cartoon character Snagglepuss - a regular on the Yogi Bear Show in the 1960s. It may have been adopted by the Yogi Bear screenwriters because it sounded wacky to American ears.
If appearance is anything to go by, Snagglepuss was the template for the later Pink Panther. The character had two catchphrases - "Exit, stage left" and "Heavens to Murgatroyd".
The expression is a variant of the earlier 'Heavens to Betsy'.