It's a euphemism for 'hell' in the same way as 'jeepers' is a euphemism for 'Jesus'. If you click here, that will link you to a web-page which offers more detail.
It comes from people that use alternate words to ameliorate the effect of curse words. (damn becomes dang, etc.) "Sam Hill" is from "damn hell." It is not a reference to a person.