Legend says that Gerry Garcia, leader of the band The Grateful Dead, found the phrase in a Funk and Wagnall's Dictionary
The dictionary entry reads along these lines:
GRATEFUL DEAD: The motif of a cycle of folk tales which begin with the hero coming upon a group of people ill-treating or refusing to bury the corpse of a man who had died without paying his debts. He gives his last penny, either to pay the man's debts or to give him a decent burial. Within a few hours he meets with a travelling companion who aids him in some impossible task, gets him a fortune or saves his life. The story ends with the companion disclosing himself as the man whose corpse the hero had befriended.(Funk & Wagnall's Dictionary).
The name has also been attributed to this quote, though it's generally believed that they came across this one later: