Old English hwæt, from Proto-Germanic *khwat (cf. Old Saxon hwat, Old Norse hvat, Danish hvad, Old Frisian hwet, Dutch wat, Old High German hwaz, German was, Gothic hva "what"), from PIE *qwod, neuter singular of *qwos "who" (see who).
Meaning "what did you say?" is recorded from c.1300; as an interrogative expletive at the end of sentences it is first recorded 1785, common early 20c. in affected British speech. Or what as an alternative end to a question is first attested 1766. "To give one what for is to respond to his remonstrant what for? by further assault" [Weekley]. The phrase is attested from 1873. What's-his-name for "unspecified person" is attested from 1690s; variant whatsisface is first recorded 1967. What's up? "what is happening?" first recorded 1881.