Choose "that" to introduce a defining relative clause and "which" to introduce a non-defining relative clause.
Probably no one considers relative pronouns exciting. Maybe most people hardly consider them at all, but writers are not most people. Good writers must know the rules of good usage. They might on occasion have good reason to ignore them, but know them they must.
So when should a writer use "that," and when "which?" Although writers have been arguing for more than a century whether it matters, the most careful writers recognize that the rule is fairly simple. Use "that" to introduce a relative clause that defines or clarifies the meaning of the antecedent noun and "which" to introduce one that does not. Or to put it another way, "that" limits the meaning of the noun and "which" does not.
Consider how the preceding sentence would change if it used the opposite pronoun: "Use 'that' to introduce a relative clause, which defines or clarifies. . ." Using "that" defines what kind of relative clause is meant, or limits the meaning of "relative clause," while using "which" does not. In the revised sentence, it gives a parenthetical fact about relative clauses in general, which in this case is incorrect; some relative clauses define or clarify, but not all do.
Notice that there is a comma before "which," but not before "that." Many writers would simply use "which" and omit the comma: "Use 'that' to introduce a relative clause which defines or clarifies. . ." Without the comma, "which" functions as if it were introducing a defining clause. It is factually correct and, in this case anyway, clear enough.
Sometimes, unfortunately, such a construction is ambiguous. Consider: "The package that arrived in bad condition had been shipped without insurance." "The package, which arrived in bad condition, had been shipped without insurance." The first sentence implies the arrival of several packages. One of them arrived in bad condition. The second does not. It simply adds a fact about a single package.
Take away the commas, but still use "which," and how is anyone to decipher the exact meaning of the sentence without stopping to study the context? And why should a reader have to stop and ponder when the writer could make the meaning obvious simply by using the correct relative pronoun and punctuation? Unfortunately, many writers find that identifying the correct relative pronoun is not simple.
1. There is no preposition that can be used before "that." If one is needed, the writer must either substitute "which," for example "for which," or put the preposition at the end of the clause. Lots of writers try to avoid the latter construction,but there is nothing wrong with a preposition at the end of the clause or sentence. English is, after all, a Germanic language, and a preposition at the end of a clause or sentence is a vestige of the German separable verb prefix. The prohibition is a leftover of a long-abandoned attempt by some grammarians to make English as much like Latin as possible.
2. A defining clause is not set off by commas, but a non-defining clause is. That is why "Use 'that' to introduce a relative clause, which defines or clarifies. . ." is incorrect. The sentence is true with a defining clause and false with a non-defining clause. A general rule of thumb is to use "which" if a relative clause has a comma before it, and to use "that" if it doesn't.
But consider the following: "The Pope attempted to abolish the use of instruments, including trombones, that he considered unsuited to the sacredness of a church." The antecedent of "that" is "instruments." Structurally, the parenthetical reference to trombones could be omitted, leaving an obvious defining relative clause. But if it is necessary in its context, then "which" would introduce a non-defining relative clause and change the meaning of the sentence.
3. With a defining clause, "that" can frequently be omitted. If it can be, it probably should be. "Which" before a non-defining clause, on the other hand, cannot be omitted. Consider: "The book that I read last night was absorbing." vs "The book, which I read last night, was absorbing." The first of the alternatives limits the entire universe of books to the one I read last night. "That" can be left out without disturbing the meaning of the sentence. In the second, presumably the book has been identified some time earlier, and the non-defining clause calls special attention to when I read it. "Which" cannot be taken out without changing the emphasis in the sentence.
4. In conversation, "that" is much more common than "which." After all, complex sentence structures are much less common in speech than in writing. Apparently, some writers have concluded that "that" is most appropriate in speech, but "which" is preferable in writing. That may be why we read so many defining clauses introduces with "which." One easy way to decide whether "that" or "which" is correct is to examine a piece of writing #yours or something someone else published# and hunt for every use of "which." Read the sentence and mentally substitute "that." The substitution may ruin the sense of the sentence. In that case, "which" is correct. If "that" works, get rid of the "which."
It would be possible to enumerate many more situations where something about a sentence complicates identifying whether a defining or a non-defining clause best suits an author's purpose. The point is that the author, not the reader, should make the effort. Laziness on this point results in either ambiguity or inaccuracy.