There are many possibilities with MIDI and you can read more about MIDI here. During playback, that number gets converted back into sound using the sound card in your computer or a keyboard connected to your computer. When recording a MIDI file, every note that you press gets converted into a number. This is because instead of recording sound to a file, when using MIDI, we record the note number, duration and other parameters about the note being played. However, with MIDI we can do all of these things. The limitations of a sound file prevent us from effectively slowing it down or transposing it to new keys or seeing on a staff what notes are being played. When recording a keyboard (digital piano), we normally think of recording a sound file like an mp3 file.
MIDI stands for Musical Instrument Digital Interface and it is a way for computers and keyboards to talk to one another.