... is to never spend it.
If you use your HSA the "right" way, you can contribute pre-tax dollars, invest, let it grow for decades, and then withdraw both the earnings and principal tax and penalty-free.
How?
Simple. Keep your medical-related receipts. There is no limit on when you reimburse yourself for a medical-related expense. Unfortunately, everyone is going to have at least some medical-related costs during their lifetime, so this does work out.
Let's look at an example. You're 30, and you had a great year at work, so you max out your HSA. You have $3,850 in your HSA, and you invest it in the S&P 500 (we'll assume a 7% average return). We'll also assume that you never contribute another dollar to your HSA.
You break your ankle playing basketball shortly after, and conveniently, you have a hospital bill for $3,850. Perfect - you can use the pre-tax dollars in your HSA to pay off your bill. But this actually would be throwing away the future earning potential of this pre-tax money. The IRS has no limit on when you reimburse yourself for this bill. So why not wait a while?
If you forget about your HSA and leave it invested, ten years later, this will have almost doubled to just over $7,078.07. When you're 40, you could withdraw $3,850 from your HSA to go on vacation somewhere and pay no tax or penalties because technically, you would just be reimbursing yourself from that hospital bill you had when you were 30. The difference here is that you still have $2,200 left in your HSA for future expenses (or hopefully, to continue to let grow).
In an alternative example, let's say that you continue to max out your HSA each year. Compounding interest is your best friend, and you're going to end up with a nice stack of pre-tax money. If you let it grow until old age, when the average person incurs most of their medical expenses, you're going to be in great shape. At 65, you'll have $820K in that HSA. And if you're lucky and don't have major health expenses, you can start to withdraw this money penalty-free at 65.
So the takeaway here is to max your HSA, save your receipts, pay your medical expenses with after-tax dollars, and let your HSA grow. You end up with a rainy-day fund you can withdraw from in the future and/or a nice addition to your retirement. You'll thank me later.
This is not financial, legal, or tax advice and should only be read for entertainment purposes.