A stop-loss is an order that automatically exits a position once the price reaches a level you set in advance. Its job is to define, before you enter, the most you are willing to lose on the trade so that no single position can do outsized damage. The distance from your entry to your stop is your risk on the trade, the basis of the R-multiple.

Why it is the foundation of risk management

Losses are unavoidable; uncontrolled losses are not. A stop-loss converts an open-ended, emotional decision (should I sell yet?) into a rule decided while you were calm. It also lets you size positions properly: once you know your stop distance, you can choose a quantity so that hitting the stop costs only a small, fixed percentage of capital. Placing stops using a volatility measure such as ATR helps set them far enough away to avoid normal noise. See F&O risk management for how this applies with leverage.