Sam Hill is an American English slang phrase, a euphemism for "Hell", or "Damn" (as in, "What in the Sam Hill is that?"). Its etymology is uncertain, however it first appeared in print in America in the Seattle Times Newspaper in reference to James J. Hill (Jim Hill). Jim Hill was the legendary "empire builder", whose railroads included the Great Northern Railway (U.S.). He was a man given to notable rages when anyone dared to oppose one of his grandiose schemes. So frequent were these tirades that the paper carried as a standing headline: "Jim Hill is as mad as Sam Hill."
Other published usages include "go like Sam Hill" or "run like Sam Hill" - in reference to Colonel Samuel Hill of Guilford, Connecticut who perpetually ran for office in the late 19th Century. However, he was apparently so unsuccessful that except for a brief mention in the Encyclopedia of American Politics, 1946 edition, there is scarce evidence that he existed.
Another explanation links the phrase to Sam Hill, an Abenaki Indian basket maker who lived near Saratoga Springs, NY in the early 19th century, known for the baskets he sold to tourists and for his disheveled appearance.
Others have suggested that the "Sam" in the phrase derives from Samiel, the name of the Devil in Der Freischütz, an opera by Carl Maria von Weber that was performed in New York in 1825.
Ultimately, the expression may simply be derived from a bowdlerization or alliteration of "hell" with "hill" when used in 19th century America by frontiersmen, especially when they needed to clean up their language in the presence of ladies.
The alternate history webcomic Roswell, Texas refers to "Sam Hill" as being a Texican monument (in the story's continuity, the Republic of Texas did not join the United States, but remained a nation unto itself) similar to Mount Rushmore, but bearing the faces of four Texas heroes named 'Sam': Sam Houston, Sam Walker, Sam Colt and Sam Clemens, a.k.a. Mark Twain.
The Oxford English Dictionary indicates that the origin is unknown. That is probably more reliable than any of the above sources.