Yes. This is a popular financial strategy among people who have many years to invest in an HSA and are able to pay for routine medical bills with non-HSA funds.
You cannot continue to contribute to an HSA once you’re enrolled in Medicare (for most people, this happens at age 65). But you can continue to use your HSA funds entirely tax-free after age 65, as long as you only withdraw money to cover qualified out-of-pocket medical expenses. And once you’re 65 and enrolled in Medicare, you can use your HSA funds to pay Medicare premiums for Part B, Part D, and Part C (Medicare Advantage).
(Medigap premiums are not considered an eligible HSA expense, so tax-free HSA funds cannot be used to pay them. And non-Medicare premiums are generally never an expense that can be covered with tax-free HSA funds, unless you’re receiving unemployment benefits or covered under COBRA. All of this is clarified in IRS Publication 969.)
And long-term care costs can also be paid with tax-free HSA funds. Long-term care is not covered by Medicare, and long-term care insurance tends to be quite expensive. If you’re able to consistently save money in an HSA over the course of several decades, you could end up with a sizeable chunk of money that can be used, tax-free, to cover the cost of long-term care.