Old English hwæt, referring to things in abstraction; also "why, wherefore; indeed, surely, truly," from Proto-Germanic pronoun *hwat (source also of Old Saxon hwat, Old Norse hvat, Danish hvad, Old Frisian hwet, Dutch wat, Old High German hwaz, German was, Gothic hva "what"), from PIE *kwod, neuter singular of *kwos "who," from PIE root *kwo-, stem of relative and interrogative pronouns. Corresponding to Latin quid.
Meaning "what did you say?" is recorded from c. 1300. As an adjective and adverb, in Old English. As a conjunction in late Old English. Exclamatory use was in Old English. What the _____ (devil, etc.) as an exclamation of surprise is from late 14c. As an interrogative expletive at the end of sentences from 1891; common in affected British speech. Or what as an alternative end to a question is first attested 1766. What have you "anything else one can think of" is from 1925. What's up? "what is happening?" first recorded 1881.
"To give one what for is to respond to his remonstrant what for? by further assault" [Weekley]. The phrase is attested from 1873; what for? as introducing a question is from 1760. To know what is what is from c. 1400; I'll tell you what to emphasize what is about to be said is in Shakespeare.
It forms all or part of: cheese (n.2) "a big thing;" cue (n.1) "stage direction;" either; hidalgo; how; kickshaw; neither; neuter; qua; quality; quandary; quantity; quasar; quasi; quasi-; query; quib; quibble; quiddity; quidnunc; quip; quodlibet; quondam; quorum; quote; quotidian; quotient; ubi; ubiquity; what; when; whence; where; whether; which; whither; who; whoever; whom; whose; why.
It is the hypothetical source of/evidence for its existence is provided by: Sanskrit kah "who, which;" Avestan ko, Hittite kuish "who;" Latin quis/quid "in what respect, to what extent; how, why," qua "where, which way," qui/quae/quod "who, which;" Lithuanian kas "who;" Old Church Slavonic kuto, Russian kto "who;" Old Irish ce, Welsh pwy "who;" Old English hwa, hwæt, hwær, etc.
"as, in the capacity of," from Latin qua "where? on which side? at which place? which way? in what direction?" figuratively "how? in what manner? by what method?; to what extent? in what degree?" correlative pronominal adverb of place (from PIE root *kwo-, stem of relative and interrogative pronouns).