To really understand the origins of MIDI, you need to go all the way back to before there were digitally controlled synthesizers and computers, In fact you need to go back before there was even electricity to the very first mechanical music machines. The very first mechanical musical instruments were documented in the Book of Ingenious Devices...
By Daderot (Own work) [Public domain], via Wikimedia Commons The golden age of mechanical music machines really came in the late 19th century and early 20th century with player pianos and orchestrions.  A player piano is defined as any actual acoustic piano that is played by a pneumatic or electro-mechanical mechanism that operates the piano action via pre-programmed music.