" I spend a lot of time with Sam."
This sentence is complete and meaningful on its own. The clause, "who came to visit me" is additional, interesting information - but not necessary to make it clear what I am referring to/talking about in the main clause. Hence, this additional information is a separate idea, and is preceded by a comma:
"I spend a lot of time with Sam, who came to visit me."
"Sam explains very simply how to use a mitre saw."
'how to use a mitre saw" is not a separate clause, but an adverbial phrase:
'explains' what?
'how to use a mitre saw'
It is part of the whole sentence and shouldn't be separated off with a comma.