How a chain ID works
When you sign a transaction, the wallet mixes the chain ID into the signature. A node on another network sees a different chain ID and rejects the transaction, which prevents replay attacks.[1]
How a chain ID is used
You enter it when adding a network to a wallet by hand, and apps use it to check that your wallet is on the right network before you sign.
The Bottom Line
The chain ID tells wallets and nodes which network a transaction belongs to. Copy it from a trusted source when adding a network.
Educational content, not financial advice.