A man tried to sell me a coffin today...
A man tried to sell me a coffin today. I told him that's the last thing I need.
This joke is a pun. The humor lies in the fact that "the last thing I need" is a phrase that means "something that I do not want", but could also mean (if taken literally) "the thing that I need last".
Were someone to die, a coffin would be a useful thing to have for them, so perhaps one could say that it is the thing that you need last.