Why Lifetimes
Preventing dangling references.
References Must Stay Valid
A reference borrows data it does not own. Rust must guarantee the data lives at least as long as the reference. Lifetimes are how the compiler tracks this.
Their job: prevent dangling references.
What Is a Dangling Reference?
A dangling reference points to memory that has been freed. In languages without checks, using one causes crashes or security bugs. Rust refuses to compile such code.