Rule 1. Who and sometimes that refer to people. That and which refer to groups or things.
Anya is the one who rescued the bird.
"The Man That Got Away" is a great song with a grammatical title.
Lokua is on the team that won first place.
She belongs to a great organization, which specializes in saving endangered species.
Rule 2a. That introduces what is called an essential clause (also known as a restrictive or defining clause). Essential clauses add information that is vital to the point of the sentence.
Example: I do not trust products that claim "all natural ingredients" because this phrase can mean almost anything.
We would not know the type of products being discussed without the that clause.
Rule 2b. Which introduces a nonessential clause (also known as a nonrestrictive or nondefining clause), which adds supplementary information.
Example: The product claiming "all natural ingredients," which appeared in the Sunday newspaper, is on sale.
The product is already identified. Therefore, which appeared in the Sunday newspaper is a nonessential clause containing additional, but not essential, information.
Essential clauses do not have commas introducing or surrounding them, whereas nonessential clauses are introduced or surrounded by commas.
Rule 3. If that has already appeared in a sentence, writers sometimes use which to introduce the next clause, whether it is essential or nonessential. This is done to avoid awkward formations.
Example: That which doesn't kill you makes you stronger.
This sentence is far preferable to the ungainly but technically correct That that doesn't kill you makes you stronger.
The distinction between that and which, though a useful guideline, is not universally accepted as a hard-and-fast rule. For many centuries and up to the present, which has been routinely used by great writers and journalists to introduce essential clauses.