EDIT 2018-12-23: Alabama actually passed a law in 2016, which took effect in 2018, that generally conforms state taxation law on HSAs with federal law. 
But Just Because They're Great Retirement Accounts Doesn't Make Them Best for You Overall
Tanja Hester at Our Next Life explains this in great detail, and you really should read her post.
That’s multiple, credible studies that conclude that high deductibles make us all avoid getting health care, including the preventive services like checkups, immunizations and screenings that are free. It’s not hard to see why that’s a problem: you’re putting off treating something until it’s more serious, when it might be harder and more expensive to treat, and you’re missing out on the opportunity to be diagnosed early for something that could be impossible to treat if not caught early on.
The only way for you to open a Health Savings Account (HSA) is to enroll in a High Deductible Health Plan (HDHP). If you're going to enroll in a HDHP, you need to be aware of these traps and actively remind yourself not to delay care.
With that being said, the HSA does have some interesting properties that make it almost act like a retirement account.
Before I get started, a disclaimer: HSAs are NOT use it or lose it. Flexible Spending Accounts (FSAs) have this provision. Not HSAs.
Money Goes into the HSA Pre-Tax
Like an IRA or 401(k), money that you contribute to a HSA goes in pre income tax. However, this is one of the few accounts that allow for contributions to also avoid payroll (Social Security + Medicare) tax (if your employer allows it). This is an extra 7.65% savings. 
Money Goes Out Tax Free for Medical Expenses
Once you incur a medical expense, you can use HSA funds tax free for qualified medical expenses.
What is a Qualified Expense?
From Publication 969
Qualified medical expenses are those expenses that generally would qualify for the medical and dental expenses deduction. These are explained in Pub. 502, Medical and Dental Expenses.
Also, non-prescription medicines (other than insulin) aren’t considered qualified medical expenses for HSA purposes. A medicine or drug will be a qualified medical expense for HSA purposes only if the medicine or drug:
- Requires a prescription,
- Is available without a prescription (an over-the-counter medicine or drug) and you get a prescription for it, or
- Is insulin.
Qualified medical expenses are those incurred by the following persons.
- You and your spouse.
- All dependents you claim on your tax return.
- Any person you could have claimed as a dependent on your return except that:
a. The person filed a joint return,
b. The person had gross income of $4,050 or more, or
c. You, or your spouse if filing jointly, could be claimed as a dependent on someone else's 2017 return.
You can’t treat insurance premiums as qualified medical expenses unless the premiums are for:
- Long-term care insurance.
- Health care continuation coverage (such as coverage under COBRA).
- Health care coverage while receiving unemployment compensation under federal or state law.
- Medicare and other health care coverage if you were 65 or older (other than premiums for a Medicare supplemental policy, such as Medigap).
If we look at Publication 502
Medical expenses are the costs of diagnosis, cure, mitigation, treatment, or prevention of disease, and the costs for treatments affecting any part or function of the body. These expenses include payments for legal medical services rendered by physicians, surgeons, dentists, and other medical practitioners. They include the costs of equipment, supplies, and diagnostic devices needed for these purposes.
Medical care expenses must be primarily to alleviate or prevent a physical or mental disability or illness. They don't include expenses that are merely beneficial to general health, such as vitamins or a vacation.
There's a long list of specific expenses singled out as includible or not. Some HSA eligible expenses that are typically not covered by health insurance plans include capital expenses to have special equipment installed in your home for medical reasons, dental treatment (assuming you only bought a health insurance plan and not a dental plan), fertility treatments, and sterilization.
You Can Defer HSA Distributions for Medical Expenses Indefinitely and Invest it Instead
When you incur a qualified medical expense, you can either choose to withdraw that amount of money from your HSA right away, or save the receipt and defer the withdrawal indefinitely. From IRS Notice 2004-50:
Q-39. When must a distribution from an HSA be taken to pay or reimburse, on a tax-free basis, qualified medical expenses incurred in the current year?
A-39. An account beneficiary may defer to later taxable years distributions from HSAs to pay or reimburse qualified medical expenses incurred in the current year as long as the expenses were incurred after the HSA was established. Similarly, a distribution from an HSA in the current year can be used to pay or reimburse expenses incurred in any prior year as long as the expenses were incurred after the HSA was established. Thus, there is no time limit on when the distribution must occur. However, to be excludable from the account beneficiary’s gross income, he or she must keep records sufficient to later show that the distributions were exclusively to pay or reimburse qualified medical expenses, that the qualified medical expenses have not been previously paid or reimbursed from another source and that the medical expenses have not been taken as an itemized deduction in any prior taxable year. See Notice 2004-2, Q&A 31 and also Notice 2004-25, for transition relief in calendar year 2004 for reimbursement of medical expenses incurred before opening an HSA.
Assuming that you have sufficient cash outside of your HSA to pay for the medical expense, it is generally a better idea to defer that withdrawal into the future. By doing so you can invest that money in the HSA and let it grow tax free before you withdraw.
You Can Withdraw Penalty (Not Tax) Free After 65
Again from Publication 969
There is an additional 20% tax on the part of your distributions not used for qualified medical expenses. Figure the tax on Form 8889 and file it with your Form 1040 or Form 1040NR.
There is no additional tax on distributions made after the date you are disabled, reach age 65, or die.
This is what makes the HSA such a great retirement account.
But HSAs Aren't as Great if You Live in CA or NJ
According to The HSA Report Card, as of the end of the 2017 tax year, California and New Jersey do not treat HSAs as retirement accounts. Contributions to HSAs are still subject to state income tax. Any dividends or interest received, and capital gains or losses realized in the account, are subject to state income tax. Finally, all distributions from the account are still subject to state income tax.
This is not to say that if you live in those states you shouldn't use HSAs. You're still getting the payroll and federal income tax deduction. Furthermore, while you might currently live in one of the three aforementioned states, by the time you withdraw from your HSA, you might not. What this does mean is that you should consider using tax efficient funds in your HSA to avoid paying state income taxes on capital gains, dividends, and interest.
Normally I would quote the part of each state's laws that specify this, but as far as I understand the law (though I am not a lawyer), I'd have to prove the absence of any special treatment of HSAs. Unless there is an exception specifically carved out in the state law, all investment accounts are treated as taxable accounts.
HSA Inheritance Laws are Highly Disadvantageous
This is in a separate post.
Though FSAs have the option of allowing up to $500 to carry over ↩︎
Though this does result in reduced Social Security benefits in the future (if you're below the Social Security wage base). It's only really a savings if you invest the money in the HSA and earn more than what Social Security would pay out. Of course, the future of Social Security is hard to predict. ↩︎