From audio files...
While etymologically the word refers to anything you can hear (and record too), the word "audio" commonly means digital audio data.
But what is a digital audio file? It's just a file with sound that has been digitized by converters the same way you can digitize pictures with a scanner.
You probably know several image file formats like GIF, JPG, PNG, TIFF, or BMP. So you won't be surprised to learn that there are also different audio file formats: WAV, AIFF, MP3, M4a, OGG, and many more. And even if they don't do it the same way, all these formats are used to store digitized sound. Double-click such a file in your computer and the latter will decode the digital data to convert it back into audible sound.
Like digital pictures and movies that have different resolutions, audio files can also have more or less definition. This will affect their size, and a high-resolution audio file will be bigger than a low-resolution one.
Now that you have an idea of what is an audio file and what it is made for, let's focus on MIDI (an enigmatic acronym that means Musical Interface for Digital Instruments — conceded, it explains nothing).
… to MIDI file
Unlike audio files, a MIDI file is not the result of sound digitization. So you will never be able to record the sound of your voice into such a file because that's not its purpose. However, MIDI and audio help you make music all the same. So what are the differences?
Let's use analogy to try to understand what is a MIDI file and where are the differences with an audio file. To a graphic designer, we could say that MIDI is to audio as vector graphics are to bitmaps. To a confectioner, we would explain that MIDI is to audio as a recipe is to a cake. To a couple that's been together for 25 years, we would say that MIDI is to audio as a blueprint is to their dream house.
For a more musical analogy, we could say that MIDI files are to audio files the same as the score of Vivaldi's Four Seasons is to the CD of Vivaldi's Four Seasons recorded by the London Philharmonic.
That is to say, unlike audio files, MIDI files include no sound at all but rather a series of commands that can only be understood by instruments supporting MIDI and which they use to play the right sound at the right time. The MIDI file itself doesn't produce any sound. The sound is generated by the MIDI instrument according to the commands included in the MIDI file.
Have you ever seen those mechanical pianos or barrel organs that play on their own thanks to punched cards? The punched card is the direct forefather of the MIDI file. Depending on the position of the holes, the piano or the organ plays particular notes at a given time and over a given duration. And while the combination of the card and the instrument generates music, the card cannot produce any music by itself: it's just a punched sheet of cardboard. The same applies to a MIDI file: it is only a set of computer commands to control a hardware or software instrument. It provides the instrument all relevant information about which note to play, when to play it and how it ought to be played. Should it be loud or not, with which sound, left or right in the stereo field, etc.
By now you have probably already understood that MIDI is a sort of descriptive language* that allows MIDI instruments to communicate with each other. This language is part of a communication standard for electronic devices with its own interfaces, cables, etc. That's why you can record notes in a MIDI sequencer with a MIDI keyboard and the sequencer will use the MIDI protocol to ensure that a MIDI sampler or synthesizer plays those notes correctly.
But — you'll say — if the goal of MIDI is to generate sound, why don't we record everything directly as audio data?
Well, because MIDI data is much smaller and easier to edit than audio data, which is bigger and less versatile. Besides the size argument, which is of interest in some applications (for a long time cell phone ring tones were MIDI files because cell phones didn't have enough storage space for audio files), the main advantage of MIDI is that it's very easily editable. Imagine you record a piano player with audio files. You'll certainly get a very authentic take, but you won't be able to change the playing speed of the musician, nor to transpose the pitch of the instrument, nor replace the original sound with bagpipes. You won't be able to edit wrong notes or rhythm problems either. The good news is MIDI gives you all these possibilities by means of a sequencer. Just like a word processor allows you to edit the font family of a text and replace a word by another as often as you want without altering the quality of the final document. And trust me, the quality you can get from a MIDI file can be very good if you read the MIDI file with a high-quality MIDI instrument.
Both on Mac OS X and Windows, the sound you get when you double-click a MIDI file is pretty bad. However, the MIDI file itself is not to blame but rather the poor quality of the sound generator used by your player. If you read the same MIDI file with high-quality MIDI instruments (be they hardware or software), you'll get very authentic results... Here you have some examples made with MIDI files and high-quality virtual instruments:
Stunning, isn't it?*
Besides playing back notes, MIDI is used for many other applications like, for instance, mixing automation (varying level and pan settings of an instrument, changing an effect setting, muting an effect, etc.) or to trigger lighting systems on stage...
To sum it up, although you can record music without ever using MIDI, which was the case before its introduction in the 80's, MIDI is a very powerful tool that makes many things much easier once you know how to use it. And it is not as complicated as it seems.
* These examples are audio bounces from MIDI files. To be fully honest, their overall sound quality is also due to the quality of the mix.