Why was the first computer made?

To break the coded messages produced on the WW2 German Enigma machine.