Dig around online for clarification on when to use that versus which and you’ll find some grammar-wonk sites that dig deep into restrictive clauses versus nonrestrictive clauses. It can be a bit confusing if grammar isn’t something that naturally flips your switch.
In an effort to put it into simpler terms, we offer this explanation: That versus which is about specificity. Consider the following examples.
Do you see it? In Sentence 1 we need to be specific about the pencil that we are requesting. There are multiple pencils on your desk. We need the one on the right. Using that here tells us what pencil we need. For the record, “that is on the right side of my desk” is a restrictive clause. You remove it and you create confusion.
In Sentence 2, we are offering more information about the location of the pencil, but it’s not information that’s necessary to identify the right pencil since there is just the one pencil. Naturally, “which is on the right side of my desk” is a nonrestrictive clause. You remove it and that sentence is still clear.