Obviously most people aren’t thinking this far ahead, but even if you have the cash, sometimes it actually makes sense to take out a loan.
Here’s where the “makes sense” becomes subjective. If your definition is absolute most cash value extracted, then yes.
However there’s a certain mental cost that you don’t escape by having to make sure you don’t get screwed on the initial loan terms, have the cash for the pay the installments, make sure the payments get to the lender, follow up on any customer services issues that occur over the life of the loan, navigate any life events which can restrict or restrain your cash flow being able to make payments (like layoff or illness), possibly liquidate holdings to free up cash to make the payment, keep track of the cash you would have spent on the car in an external account earning the best return you can get (with varying interest rates or market conditions).
…or you can pay for the car outright one time, and never think about those things again for that car possible for a decade or more. Today’s life is filled with many such mental burdens. The value in being able to simply never have this worry is very underrated in my opinion. This is one component to approach a care-free lifestyle while still maintaining your responsibilities and freedoms.
What you’re describing there to me is an anti-pattern. If you have to spend $20k to buy a car and you blow through your entire emergency fund to do it bringing your emergency fund to $0, you’ve already made a mistake. To use your numbers, if you have $20k and you need a car. You buy a $15k car. You have a fully paid off car, and an extra $5k in the bank for emergencies. Further, I still make a car payment, but to myself, every month that goes into savings to buy the next car outright. Its easy to do because I don’t have a real car payment to a bank. If money is ever tight, I can choose to not make my “car payment” to myself giving me more flexibility, liquidity, and less overall worry. A year after this purchase and even after the $5k emergency, I have $3900 positive in savings from my “car payment to myself” and still have a paid off car.
Continue to play that out with a more likely bad case scenario. You start with $18k in the bank, and you’ve now leveraged your emergency fund to also cover car. You have your theoretical $5k emergency dip into it leaving you with $13k in the bank. A year later, you lose your job. Your car payment is still due, you have the remainder of the real car payments to make at $325/month to the bank. So now you’re drawing down your savings (and the money you would have paid off the car with) just to live on. You can try to sell the car, but its depreciated and you’re not going to get even enough money to pay off the bank note. You took on the worry of this and this risk everyday for five years to try to make about a measly ~$1k profit.
I’m not saying this is exactly how its going to happen, but in your scenario the possibility exists for this. In my “buy the car outright” it doesn’t. How often in life does everything go perfectly for you? My experience says, not often.