Your transaction sits in the mempool before it executes, and the pool can change in that time. Tolerance sets a floor on what you will accept, enforced by the contract as a minimum output, so the trade reverts rather than filling far away from expectation.
The setting is a genuine trade-off. A 0.1% tolerance on a volatile pair will often revert and cost you gas for a failed-transaction. A 20% tolerance guarantees execution and tells a sandwich-attack bot exactly how much value it can extract from you: it can move the price up to your limit, let you fill at the worst allowed price, and sell back.
Practical habits: keep tolerance as tight as the pair allows, around 0.1% to 0.5% for deep stable pairs and 1% to 3% for volatile ones, be suspicious of any interface demanding a huge tolerance since that often signals a transfer-tax or honeypot-token, and use a private-mempool for large swaps.
Related: price-impact, sandwich-attack, failed-transaction, private-mempool