Coal miners would bring canaries down into the tunnels with them. If dangerous gases collected in the mine, they would kill the canary before killing the miners. It served as a warning system to evacuate the mining tunnels.
Today, it’s a useful metaphor for early warning signs that something is about to happen.