Whoever builds a block decides the sequence, and sequence is worth money. Seeing a pending swap lets a bot trade ahead of it; seeing an undercollateralised loan lets a bot claim the liquidation-bonus first. That extractable value is MEV, and it runs to hundreds of millions of dollars a year across chains.
Not all of it is predatory. Arbitrage that aligns a dex price with the wider market and liquidations that keep lending markets solvent are necessary work, and the competition for them is healthy. sandwich-attacks, by contrast, are a straight transfer from a retail trader to a bot.
Modern infrastructure separates searchers, who find opportunities, from builders, who assemble blocks, from proposers, who publish them, with bids flowing back down the chain. For a trader the actionable parts are small: keep slippage-tolerance tight, use a private-mempool for size, and avoid broadcasting large swaps into a public queue.
Related: sandwich-attack, private-mempool, front-running-onchain, arbitrage-bot