Excerpt from L is for Lollygag, Quirky Words for a Clever Tongue (Chronicle Books, San Francisco)
I came across this superb table of superior ancestors to the newfangled, vile acronym "WTF" in a delightfully cheering wee gem of a book titled L is for Lollygag, Quirky Words for a Clever Tongue.
Some of them I've heard. My grandmother definitely used "for Pete's sake", "sake's alive", "land sakes", "heavens to Betsy", and "for crying out loud", but then one of them jumped out at me not because of its familiarity, but rather for its complete oddity, and that was "what in Sam Hill?!?".
Being a savvy sort of woman, I went and asked Wikipedia, who told me that it's a euphemism for hell or devil. But then I needed to find out who or what the devil Sam Hill was.
It turns out the most probable origin of the expression is an exceptionally diversely stocked store founded by a Mr. Sam Hill and still standing on Montezuma Street in Prescott, Arizona. For the locals, things that were the most odd and unusual were like something that could be found at Sam Hill Mercantile. From there the expression spread throughout the U.S.
However, the definitive origin of "what in sam hill" isn't all that important, because the meaning is made obvious by your tone, which leads one to experiment with other possibilities. I think a potential and fitting candidate to replace some of the tired contemporary curses and euphemisms may be "What in Walmart?!?" and I plan on using it myself. You may borrow it if you wish.