Both demonstrative pronouns come from the same two Proto-Indo-European stems: *so- / *sa- and *to-.
Originally, in Indo-European languages there was a three-grade system of demonstrative pronouns, namely
"this, next to me",
"this, next to you",
"that, far from both of us".
But, as well as many branches of the family, Germanic languages left only two of them, simplifying the structure to just
"this" and " that".