This nautical term refers to ships that have been beached. Read about it here . When the phrase is used these days it is usually in the figurative sense and means that a situation or person is left stranded or without help.
This is an idiom that originated in America and the history of it is pretty unknown. Read about its obscure history here . The phrase means to be involved in a great difficulty or encounter an obstacle.
The source of this phrase is often said to be the fact that the best cuts of meat on a pig come from the back and upper leg and that the wealthy ate cuts from 'high on the hog', while the paupers ate belly pork and trotters. ( source ) Evolved for today's use it means that someone is affluent and can afford luxuries others cannot.