The distinction between “that” and “which” beginning a subordinate clause proves easier to write than explain. Take these two sentences:
This is the ball that Beckham kicked into the goal.
This soccer ball, which doesn’t cost much, is worth more after Beckham scores with it.
In each case, the antecedent, or the thing referred to, is “ball.” The relative clause refers to the antecedent, and either limits it or not. In the first example, “ball’ refers to a specific ball because the clause “that Beckham kicked” limits the reference to that ball. In the second example, “ball” refers to soccer balls in general, because the clause “which doesn’t cost much” does not limit it to a specific ball.
Traditionally we call these “restrictive” and “non-restrictive” clauses, or “essential” and “non-essential.” Clauses that limit the antecedent begin with “that,” and clauses that do not limit the antecedent begin with “which.”
We usually surround non-limiting clauses with commas. Strunk and White explain non-limiting clauses as parenthetical, and therefore set off with commas. One test works like this. Draft the sentence, then put commas around the relative clause. If the sentence works when you read it, leave it alone. Otherwise, delete the commas. Let’s test the first example above: “This is the ball, that Beckham kicked into the goal.” It doesn’t work, and we delete the comma.
Common usage, especially in conversation, does not observe this distinction, and choosing “which” for both cases occurs more often. Using this distinction tends to remind readers of schoolteacher grammarians, and makes prose sound more “correct,” and therefore more formal.