The simplest way to expalin MIDI - musical instrument digital interface - is to think of it was a way keybords and other electronic musical instruments talk to each other.
Back in the old days (shows my age) the only way to connect MIDI was via large 5-PIN DIN cables.
Most MIDI instruments had 2 or 3 MIDI ports (IN, OUT and THRU)
Suppose you had 2 keyboards (K1 and K2) with MIDI.
If you hooked up a cable to the MIDI OUT of K1 and to MIDI IN of K2, you can "remote control" K2 from K1.
In other other words, whatever key you hit on K1, K2 will now respond (as well as producing sound form K1 as normal).
If K2 had a THRU port, you could connect that to a 3rd keyboard's MIDI IN, and you can play all three keyboards from K1.... etc
MIDI was also designed to transmit information to/from Sequencers to record/playback songs.
So that was the "good old days".
TODAY - many keyboards have a USB port in addition to, or instead of (more likely), MIDI ports.
The priciple is sort of the same.
The USB port now acts as a combined MIDI IN and OUT to communicate to a computer.
So instead of connecting a whole series of keybords together thru the MIDI ports, you connect multiple keybords to one computer (PC or Laptop). You can then do things like remote controlling other keyboards from one etc.
Sequencers have been replaced by computer software - eg Anvil Studios - where you can write a piece of music on the computer, and then play it back over MIDI through your keyboard.
Similarly, you can use the keyboard to input the notes into the sequencer software through the MIDI
Hope this makes sense.....
The Y-man