What is an Ansible handler, and what problem does it solve?
A handler is a task that runs only when another task notifies it, typically to restart or reload a service after its configuration was changed.
Some actions only make sense as a reaction. If a task rewrites a service's configuration file, the service has to be restarted or reloaded for the new configuration to take effect. If the file was already correct, a restart would be pointless downtime.
A plain task can't express "only if the file changed": it would restart every run. A handler can. Tasks name it in a notify list, and Ansible queues it only when such a task actually changed something. Handlers can be thought of as inactive tasks that wait to be woken up; apart from that, they are written like any other task and can use any module.
Because Ansible is idempotent (a second run changes nothing if the host is already in the desired state), handlers fit naturally: the first run changes the file and restarts the service once; later runs find the file correct and leave the service alone.
Go deeper:
Handlers: running operations on change (official docs) — the full reference.
Ansible 101, Episode 5: playbook handlers, environment vars and variables (Jeff Geerling) — handlers built up live in a real playbook.