That, which, and who when used as relative pronouns each has a distinct function.
In modern speech, which refers only to things. Who (or its forms whom and whose) refers only to people. That normally refers to things but it may refer to a class or type of person.
Examples: That is a book which I need for the class.
These are the books that I need for the class.
He is the man who will be teaching the class.
They are the type of people who would lie to their mothers.
They are the type of people that would lie to their mothers.
(That is OK here because it is a class or type.)
Some teachers also tell you that that should be used with restrictive modifiers and that which should be used with nonrestrictive modifiers. Historically, there is little evidence that this “rule” ever had a significant effect on English expression, but writers should be aware that some correspondents have been taught this practice.
Sometimes using which for a restrictive modifier can make a sentence sound better, especially if the sentence already uses the word that (as in the first example above).
This “rule” can cause confusion with multiple clauses, questions, or certain constructions and compounds which use that. It is better to communicate more clearly than to worry about a questionable “rule.”