Codes have been used since ancient times to send messages over long distances or encrypt messages so others cannot understand their content.
Morse code was originally developed as a method of standardising communication on Samuel Morse's electric telegraph in the mid 1830's. It has changed a number of times over the years to what is now known as the International Morse Code.
Codes have been especially predominant in wartime. Check out the following information on the German Enigma Machine that was essential for communication between German commanders in World War 2.
Codes are extremely important in computer programmes as well... what you're using right now!