The meaning is simple enough: it’s just a mild exclamation of shock or surprise. It is almost exclusively an American expression. As to where it came from, nobody has the slightest idea. It seems to be one of those traditional sayings that have been around in the language for generations, but which only latterly have come to be recorded in print. The big Oxford English Dictionary has a first citation from 1914, but I’m told it can be found as far back as 1891. Some have tried to trace it to the Revolutionary War and to Betsy Ross, but have failed; others think it may have something to do with the frontiersman’s rifle, often called Old Betsy, but there’s no evidence that saying and name are associated. Charles Earle Funk, who in 1955 used the phrase as part of the title of a book about curious phrases, said that its origins were “completely unsolvable”. We have to leave it as one of the great mysteries of lexicography, along with the similar heavens to Murgatroyd. Unless someone reading this knows different?