My understanding is that MIDI files use fixed numbers/names for all notes, as shown e.g. in this chart. At the same time, MIDI has a "key signature" meta-event. What's the purpose of the key signature information? Isn't it unnecessary?
It won't go out the midi port to your keyboard, but the midi sequencer programs that display notation need it if they're going to show the music in standard notation. It's also helpful if you're a composer and want to know what the key is. Without it, a C4 might be the I, or might be the fifth or somewhere else in the key. You could generally guess based on the notes you have assuming it's western music, but the key signature makes it concrete.
Standard MIDI files (SMF) are designed to be portable between different kinds of DAW (digital audio workstation) and other hardware and software apps and systems, so that a musician can open up the SMF in any DAW and continue working on it and modifying it.
Many DAWs can take information from a Standard MIDI file and derive or calculate chord progressions and information about the structure of the song, etc. MIDI files can include song lyrics, meter signatures, tempos, tempo changes, changes in meter, changes in key, names of musical instruments attached to each track, patch changes, and other information that goes way beyond just the notes themselves.
Many DAWs can also take MIDI data and display it not only as event lists or piano-roll notation but also as standard music notation. But in order to do that accurately, it's helpful if the Standard MIDI File indicates key signatures, so the DAW can figure out whether pitches should be labelled as flat notes or sharp notes in the display.
If somebody who creates a Standard MIDI File wants to label it with a key signature, or wants to label different sections within the song with different key signatures, isn't that a desirable and useful piece of information? The Standard MIDI File specification supports that feature, so musicians use it.
DJs like to have their tracks, whether MIDI files or audio, labeled and cataloged by key signature and tempo (beats per minute). Having this data already embedded in the Standard MIDI File is helpful to them.
Many DAWs utilize this to automatically transpose the MIDI notes incase you change the key after you composed it. For ex, if you composed a song in C, and you change the key signature in your DAW to D, all the notes will be transposed and played appropriately.
I think that my Midi arranger (Solton MS-80) displays the current key or at least uses it for enharmonic interpretation of the current chord. Key signature events most certainly are part of the realtime Midi stream and not just contained in Midi files.