The meaning is simple enough: it’s just a mild exclamation of shock or surprise. It is almost exclusively an American expression, associated in my mind with mature females of the Prohibition era or earlier (though this may just be a reflection of my recent reading). 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?
For many years, Smart Alec or Smart Aleck was thought to be no more than a generic character, first cousin to Clever Dick. The problem with seeking his original is the obvious one that, with so many possible candidates, only a stroke of luck might lead a researcher to the right Alec. A plausible candidate has been put forward by Professor Gerald Cohen (for the full story, see G L Cohen, Studies in Slang, Part 1, 1985). He argues that the original was Alex Hoag, a celebrated and clever thief in New York in the 1840s.
Hoag worked with his prostitute wife Melinda and an accomplice called French Jack to fleece unwary visitors to the city who were looking for a little fun. The key to his activities was that they did so in close association with two police officers, who shared the loot and provided protection. Most was done by what was in effect pickpocketing, with Melinda taking the victim’s pocketbook while they were otherwise engaged and surreptitiously handing it to Hoag or French Jack as they walked by. So far, so commonplace. However, his downfall came because he got into financial difficulties and tried to cheat his police protectors out of their share of the loot. One way was that Hoag lay behind a wall in a churchyard and had Melinda drop the goods over the wall to him so that the constables couldn’t see the exchange.
Another of the standard frauds, practised by many, was called the panel game. George Wilkes, the assistant editor of the Subterranean, met Hoag while Wilkes was falsely imprisoned in the infamous New York prison called The Tombs. Wilkes described the trick in a diary of 1844, The Mysteries of the Tombs: “Melinda would make her victim lay his clothes, as he took them off, upon a chair at the head of the bed near the secret panel, and then take him to her arms and closely draw the curtains of the bed. As soon as everything was right and the dupe not likely to heed outside noises, the traitress would give a cough, and the faithful Aleck would slily enter, rifle the pockets of every farthing or valuable thing, and finally disappear as mysteriously as he entered.” The victim was then persuaded to leave in a hurry through a window by Alec banging on the door, pretending to be an aggrieved husband who has suddenly returned from a trip away.
Hoag used this trick to avoid paying off his police protectors, so that when he was caught, the police were in no mood to aid him. He was sentenced to jail, but escaped through the help of his brother, only to be recaptured following extensive police searches (by one of those odd coincidences, having been recognised by Wilkes).
Professor Cohen suggests that Alex Hoag was given the sobriquet of smart Alec by the police for being a resourceful thief who outsmarted himself by trying to avoid paying graft. It’s impossible to be certain this is the true story, since the expression doesn’t appear in print until 1865, but it does seem extremely plausible.