HTML encoding transforms special characters like ``, and `&` into their HTML entity equivalents, preventing scripts from being interpreted by the browser. This helps defend against stored XSS attacks, where malicious scripts are saved in the database and executed in users' browsers. If an e-commerce site stores user reviews, encoding these inputs before displaying them ensures no scripts run unexpectedly.