-I couldn't pass the course, which is why I have to take it again.
In such sentences, which directly refers to the sentence preceding it, and we should put a comma before it.
We can't start a new sentence by which.
-I couldn't pass the course. That is why I have to take it again.
In this one, that, even though it is semantically related to the sentence before it, canstart a new sentence and isn't structurally dependent on the preceding sentence.
I don't find it necessary to get into more detail.