The story
Originally a contraction of what kind (of) (the DSL traces the Scots cognate back to Middle English whatkin, whatkyn, but the MED's only example is of the two-word collocation what kyn), later used in place of bare what.
Etymology from Wiktionary, CC BY-SA 4.0.