It is widely believed to have stemmed from the Hindu belief of reincarnation. Travelers commonly shout the expression as to not hit one of these "reincarnated creatures" while driving. Others derive the origins back to the story from Exodus of the golden calf or the "Holy Cow."
From the Dictionary of American Slang (1960):
"Holy Buckets!" Equiv. to "Holy cats!" or "Holy Mike!" both being euphemisms for "Holy Christ!". This term is considered to be very popular among teenagers, and most teens claim it is definitely a very popular phrase. It is also the common oath and popular exclamation put into the mouths of teenagers by many script writers, and, is universally heard on radio, television, and in the movies. It was first popularized by the "Corliss Archer" series of short stories, television programs, and movies, which attempted to show the humorous, homey side of teenage life.
Paul Beale (1985), however, in revising Eric Partridge's "Dictionary of Catch Phrases American and British" cites a different origin:
The original 'Captain Marvel' and 'Batman' oaths, 'holy (something harmless),' were in turn spoofed in the later 20th century by whatever seemed relevant to the situation. Nigel Rees, in Very Interesting... But Stupid: Catchphrases from the World of Entertainment, 1980, instances "holy flypaper!", "holy cow!", "holy felony!", "holy geography!," "holy schizophrenia!", "holy haberdashery!", etc., and adds, "The prefix 'holy' to any exclamation was particularly the province of Batman and [his boy assistant] Robin, characters created by Bob Kane and featured in best-selling comic books for over thirty years before they were portrayed by Adam West and Burt Ward in the TV film series."
Bullshit! hosts Penn and Teller criticize an opponent of the use of profanity who recommends saying 'santa vaca', the Spanish equivalent to holy cow. While the opponent says that her term does not offend anyone in the way that profane language does, Penn and Teller point out that to a Hindu, holy cow would be very offensive.
The term holy cow came from the indian culture were the cow is considered sacred.