As innocent as it seems today, the expression “holy mackerel” began as a blasphemous Protestant oath against the Friday fish-eating habit of Catholics.
The fish was an early symbol of Christianity.
Likewise, “holy smokes” is a snide reference to religious incense burning, while “holy cow” is a shot at Hindus who consider cows sacred.
“Holy moley” is an abbreviation of “holy Moses.”
Euphemisms are used as curses without direct reference to a religious icon.
Even though it is clear what they mean, it is a way of swearing without offending the pious.