In 1832 Samuel F.B. Morse invented the electric telegraph, and in 1875 Alexander Graham Bell invented the telephone.
Communication now becomes a business, and efficiency translates more or less directly into money.
This is a powerful encouragement to design good ways of passing messages. Morse code began as a code-book system, where sequences of long and short dashes represented not letters, as they do in what we know as Morse code, but whole words. Maybe not, since egregiously stupid things like using especially long codes for especially short words will make extra work for the telegraphist. It rapidly became clear that whole word codes were not ideal, so the move was made to an alphabetic cipher, which being relatively short, could be memorised by every clerk. Morse did realise that the code would work better if common letters had short codes, but did not actually take the trouble to count letters in a sample of text, preferring to derive his estimate from a quick glance at the relative proportions of different letters in the compartments of printer's type box.