ELI3: I buy a car from you via an online website. We agree to use a broker. I give the money to the broker and you give the car to them. They do the necessary checks and complete the exchange.
ELI10+: MQTT is a protocol — a way of communicating between different pieces of software (services). HTTP, on which the internet is built, is also a protocol.
MQTT is a pub-sub (publish-subscription) protocol, whereas HTTP is a client-server protocol. The browser is your client and the server is where you are connecting to. Pub-sub means there are publishers (producers) of information and subscribers (consumers) of information. To keep things nicely separated, you publish and subscribe to topics (like queues). A topic looks like a path: a kind of hierarchy to organise and group things, e.g. /living_room/light/status
.
In principle, you can have multiple publishers and subscribers to one topic, but usually you only have one publisher and one or more subscribers. If you strictly have only one at either end, it’s basically a queue.
The thing in the middle is called a broker. Mosquitto is such a piece of software. The broker will handle the marshalling of messages. MQTT brokers can only keep one message per topic at a time, which means, given my queue analogy from before, that it’s a queue of one. The broker can also handle whether the last value must be retained and what must happen when a client unexpectedly disconnects (LWT or last will and testament). Note that in this world, the publishers and subscribers are both clients connecting to a server (the broker). QoS or quality of service refers to with what guarantee a message must be delivered.
This pub-sub pattern is useful for asynchronous applications, i.e. where you don’t want to wait for the receiver of your message to respond before you proceed. It also means the receiver can process at their own leisure.
Using a standard protocol such as MQTT (just like for HTTP) means anybody in the world can implement the specification and have interoperability, regardless of other tech choices.
https://www.hivemq.com/mqtt/mqtt-protocol/
I forgot to add the HA bits: Thus, the MQTT integration is a client that can publish or subscribe to messages. The Mosquitto add-on (if you use add-ons) is the broker. Any device (e.g. a light) that connects to the broker is also a client.