Old English þæt, neuter singular of the demonstrative pronoun and adjective (corresponding to masc. se, fem. seo), from Proto-Germanic *that, from PIE *tod-, extended form of demonstrative pronomial base *to- (cf. Sanskrit ta-, Lithuanian and Old Church Slavonic to, Greek to "the," Latin talis "such"). Cf. the.
Emerged c.1200 as a demonstrative adjective with the breakdown of the Old English grammatical gender system, perhaps by influence of French and Latin, which had demonstrative adjectives (Old English did not). Slang that way "in love" first recorded 1929. That-a-way is recorded from 1839. "Take that!" said while delivering a blow, is recorded from early 15c.