The answer is in the Wikipedia entry for vi. Bill Joy, who wrote the visual mode of ex – which ended up being Vim’s precursor vi – used a Lear Siegler ADM-3A terminal on which the HJKL keys mapped to left, down, up, right – and it’s been that way ever since.
Here’s the keyboard layout:
A couple of other points of note on the ADM-3A layout:
- Left of the Q: the escape key – somewhat handier than where it is on keyboards today, hence a good choice for switching between normal and insert modes.
- Top right: the ‘Home’ key doubles as the tilde (~), which subsequently became shorthand for a Unix user’s home directory.