Basic Midi Setup
This is a basic modern midi setup when using a computer sequencer and several midi instruments.

Rather than to lay out a foundation describing the basics of midi, let's jump right into a typical modern hardware midi setup. It has a midi controller, a computer running a sequencer (it could be Apple Logic Pro X, Ableton Live, Steinberg Cubase, Cockos Reaper, MOTU Digital Performer, Avid/Digidesign Pro Tools, Renoise, Bitwig Studio, FL Studio, BandLab Cakewalk, Opcode Vision, Voyetra Digital Orchestrator Pro or Sequencer Gold Plus, Passport Master Tracks Pro), a thru box, and several midi instruments. The midi instruments could be synthesizers (either keyboards or sound modules), samplers, or drum machine. Most common midi signals are midi note on and note off signals. Each signal specifies a midi note number between 0 and 127. When a midi note on signal is received by an instrument, it plays a sound. When it receives a midi note off signal, it can start to end the playing of a sound. The midi interface can have one midi out, which goes into the midi thru box, and is then split to each instrument. Each midi instrument is set to one (or in the case of multitimbral instruments, more than one) midi channel. Midi channels allow instruments to only respond with a sound or a note you intend them to by assigning a unique channel number for each instrument and addressing that channel in your midi sequencing software. The midi channel that the controller will address is set in the midi sequencing software. Each track in the sequencer is set to output on a different midi channel.
Midi connectors are a 5 pin DIN jacks on the back of midi compatible equipment. They are connected together with 5 pin DIN plugs on each end, connected together with three conductor wires inside, which are called midi cables. All midi instruments that produce sounds have a midi In. They, by definition, must have a midi input. Some midi instruments have a midi out and a midi thru. In most cases there is no need to connect the midi out of the instruments being controlled by midi (the exception being if if you are performing patch dumps between the computer and the synthesizer). In most cases there is no need for a midi interface with multiple outputs (output 1, output 2, ect). Midi interfaces with multiple midi outputs that are numbered can address 16 midi channels on each one (for for Midi Out 1 and Midi Out 2 that is 32 addressable channels). If you do not have more than 16 midi instruments or if you will not be using a midi instrument that is multi timbral, a midi interfaces with a single midi output (as well as a single midi input) will be fine in this type of setup. Midi interfaces with multiple outputs that are not labeled with numbers have an integrated thru box. These types of midi interfaces can only address 16 midi channels. A midi thru box takes a single midi signal and splits it to multiple midi DIN connectors.
Any midi controller can work with any midi instrument. Midi is standardized in a way where this statement is always true. However, there are some midi controllers that have integrated USB midi interfaces and may be missing a midi output DIN connector. In this case, if the controller is to be connected to the computer with USB, an additional midi interface is required to get a standard midi DIN output connected to the other instruments in the setup.
A Midi thru port on a midi instrument will duplicates whatever is coming into the midi input and sends it to the midi output. However, this can introduce latency to the next device down the chain. This is why Midi thru boxes are ideal, they do not introduce latency.
A midi controller can also be a synthesizer keyboard. In this case we would have a thru box output connected back into that synthesizers midi input. But in this diagram we assume this is only a midi controller. A category of keyboard referred to as a midi controller will have no internal sounds, and thus no midi input and no audio output.
Not shown in this diagram are the audio connections. We will cover that that in another section.