When MIDI sequencers hit the consumer market in the 1980s they changed the face of music making forever. Free of many of the constraints of audio, MIDI allowed home users to create large multitrack files with editing facilities that were not possible with audio at the time. MIDI sequencers later embraced audio recording, and modern sequencers such as Cubase SX, Logic, Pro Tools and Sonar offer an all in one solution. Despite this progress, the MIDI side of sequencing has changed very little.
MIDI is a protocol for carrying musical information. Unlike audio files such as .wav and .mp3, MIDI doesn't carry any actual 'sound', but rather note information. The most common information is note on, velocity and note off. These 3 values determine that a note is struck (note on), how hard it is struck (velocity) and that the note is released (note off). Other information can be also be sent via MIDI such as Pitch Bend, Modulation and instrument changes. As this information is recorded numerically, then editing of the information after recording is possible. Poor timing and bum notes (in fact any MIDI information) can all be rectified after recording if using a MIDI sequencer.
A MIDI sequencer is a piece of software (although hardware units do exist) that allows the recording, manipulation and playback of MIDI information. As previously mentioned MIDI only carries note information, not audio information, so the MIDI messages are routed to a sound source such as a Hardware Sound Module/Keyboard like the Roland XV-2020 or to a VSTi/Soft Synth like Native Instruments B4 II.
Most modern MIDI sequencers work in a similar way with a main arrange window similar to the one below;

In the above screenshot you can see MIDI Tracks on the left hand side of the screen. In the centre of the screen you can see MIDI Parts.
A MIDI Track determines where the MIDI information is coming from and where it is being sent. If you are using your MIDI keyboard to input the notes, you would set the Input of the track to the same MIDI port and channel as your keyboard. You would also route the Output of the track to either a hardware sound module or VSTi/Soft Synth Below you can see I am routing the output of MIDI Track 1 to EVP73, a VSTi emulating a Fender Rhodes.

Each of the output options is a Port - this is either a hardware port, such as on a hardware MIDI interface, or a virtual/software port, such as the port I am choosing above. Each port can carry 16 channels, so with a 2 port MIDI interface such as the MIDISPORT 2x2, you can send out a total of 32 discrete MIDI channels to hardware devices. Soft Synths and VSTi's will create their own virtual ports that appear in the Output options.
When you hit record and start playing, the MIDI information will be recorded in a MIDI Part on the selected track. From the above pictures you can see that I have recorded 4 parts (Rhodes, Organ, Bass & Drums) on 4 different MIDI tracks. Once these parts are recorded you can manipulate them in several ways. The most common way of editing MIDI parts is using the Key/Piano-Roll Editor as shown below;
This method shows a set of piano keys to the left of the screen and all the recorded notes in the part to the right of the keys. As all these notes are only numerical data they can be easily moved and/or changed in duration. An alternative way of viewing and editing the MIDI information is the List Editor;

This view gives you more information about the data for each MIDI note or event. From the information in the screen above you can seen the exact note on and note off times as well as the velocity and musical note. The list editor is useful for editing MIDI information such as SysEx information that doesn't show up in the piano roll editor.
Due to the the numerical nature of MIDI, criteria such as tempo and time signature can be instantly altered after recording with no degradation to sound quality. Audio parts by contrast must be time-stretched or cut-up and quantized to achieve the same result. On the left is a screenshot of the tempo track - in this example the music starts of at 120bpm in 4/4, changes to 100bpm 3/4 at bar 5 before jumping to 150bpm 4/4 at bar 9. Changing parameters such as this post-performance is extremely difficult with audio but extremely simple with MIDI.
The quantize function found in most MIDI sequencers also allow you to tighten the recorded performance by snapping notes to a defined musical grid. This is very useful for performances with poor timing, or for changing the 'feel' of a piece.
The musical key of a piece can also easily be changed with MIDI parts by using the transpose function, and more complex functions even allow you to change the key from major to minor (or vice versa) by automatically transposing the relevant notes.
This kind of flexibility has ensured the longevity of the MIDI sequencer, and with the seamless integration of audio into most modern software sequencers it would appear that most of us will be using MIDI sequencers for the forseeable future.