The opening to Merriam-Webster’s guide on when to use ‘that’ and when to use ‘which’ is incredible:
Do you suffer from low self-esteem? Do you have anxiety, or difficulty making decisions? Do you find yourself unable to decide whether you should use that or which when composing a sentence? In the event that you answered “yes” to either of the first two questions you have our sympathies, but as a dictionary we can offer little else. However, if the source of your trouble is the issue of that and which we may be of some small assistance.