An emergency fund — commonly 3–6 months of essential expenses in boring, instantly accessible cash — looks irrational on a spreadsheet. Cash loses to inflation, and that money could be invested. But the spreadsheet is measuring the wrong thing. The fund's purpose is to make sure a car repair, a medical bill, or a job loss doesn't force you to sell investments at the worst possible moment or take on 22% credit-card debt.
That's the actual math: without a buffer, a $2,000 emergency during a market downturn converts into either locking in losses or years of compounding debt. The emergency fund is insurance against being forced to act, and its return isn't the interest it earns — it's the catastrophic decisions it prevents. This is also why it belongs before investing in the standard sequence: there's no point building a portfolio you'll be forced to liquidate.