I find it helpful to consider that both "this" and "that" have conventions, that come from their position in a sentence, and the joining words which come immediately before and after them. When used in close proximity, this and that provide a "left hand" and "right hand" to the reader. "This on the one hand" versus "That, on the other hand", is implied.
But when not used in close proximity, there are other rules. And there is not one simple way to tell which of the two would be correct.
"This is why" and "That is why" are mutually interchangeable, but "That which" and "This which" are not.
"That which does not kill you makes you stronger" is considered idiomatic, and "This which does not kill you makes you stronger" is awkward because people expect "that which", and "this which" is awkward or at least not in common usage.
I gave a specific example, but I think I could give a few hundred more.
In short, in many places they are interchangeable, and in many, many more, they are not interchangeable, and the sense of distance (this=closer, that=farther) is not even a rough guide, because the usage is, as often happens, kind of random and established not through logical rules but by arbitrary patterns of usage.
It is very easy to say something awkward if you don't follow the established patterns, "this" and "that" have sense or contextual-meaning based on the words around them, and the idiomatic senses that these words gather from the words immediately before and after them.
I studied Hindi language, and the language has some words like "jo" (जो) and "to" ( तो )which had sense or meaning, only as part of larger phrases. After studying hindi, and puzzling over the lack of sense in the word by itself, I realized that the same is true, although to a lesser degree in the case of "this" and "that", of many small words in English, and French, and in perhaps, every human language.
I wonder if there is a word for a pair of words, like "this and that", or "hither and yon" that while not opposites, are complementary, like salt and pepper.