What actually is MIDI and how does it function in a system?
Midi is an interface standard, a physical communication interface and protocol standard. 

It was designed to let electronic instruments and synthesizers communicate with each other to allow performers to produce live music. 

Midi controllers send notes to midi synthesizers for them to generate sounds. 

Its basic representation is in terms of channels/instruments/controllers, notes, and timings. That allows midi files (controller commands) to be rather small. 

Although it is possible, I really doubt the sound card understands midi at all. Instead it is more likely that a software synthesizer generates the requested sounds.