It is an exclamation
of surprise. Holy Mackerel dates back at least 200 years
and is one of very many blasphemous oaths with the Holy
prefix. Holy Mackerel was almost certainly a reference to
Catholics eating fish on Fridays (rather like Holy Cow is
a reference to Hindus, and Holy Smoke is a reference to
incense burning and funeral pyres. Mackerel was popular
because it did not cost much.
Holy Moses was shortened to the rhyming Holy Moley or Holy
Moly. The way that words roll off the tongue is
significant in how these expressions become widely used
and adopted.
Another slang for Catholics of the 19th century was
mackerel snatchers. The word Mackerel has historically
been a strong fish symbol and fish stereotype.