Wiktionary says the expression was first recorded in 1803, and was perhaps a euphemism for Holy Mary. Yahoo Answers describes it as one of many “mock” or “silly oaths” used to express surprise, emotion, or anger in a non-offensive manner. The expression apparently originated from the term “mackerel snappers,” a mock term for Catholics and their practice of eating fish on Fridays. There is an endless list of companion expressions, such as holy cow, holy buckets, and holy almost anything else. The list was expanded by the Batman and Robin television show in which Robin would exclaim something such as, “Holy felony, Batman,” or some other variation depending on the situation.