In more detail
It resolves to 127.0.0.1 in IPv4 and ::1 in IPv6, and the whole 127.0.0.0/8 block (16,777,216 addresses) is reserved for loopback. Loopback traffic never leaves the machine or touches the network card. RFC 6761 reserves the name localhost for this purpose. Developers run test servers on localhost, for example http://localhost:3000, so nobody else on the network can reach them.
Why it matters
The address a server binds to decides who can reach it. Bound to 127.0.0.1, it answers only this computer, so a phone on the same Wi-Fi cannot open it; bound to 0.0.0.0, it listens on every interface, and a database bound that way by mistake may be exposed to the network. Inside a Docker container, localhost means the container itself, not the host machine, a frequent source of "connection refused".
Example
python3 -m http.server 8000 --bind 127.0.0.1
This serves the current folder at http://localhost:8000/ for this computer only. Dropping --bind 127.0.0.1 makes it listen on all interfaces, reachable by other devices at the machine's IP address.