Adding to what Diane C said.
In a taxable account, you may pay taxes 3 times:
1) On the money you have earned from salary/wages before you invest it
2) On dividends/interest while you hold the investment
3) On gains when you sell the investment.
An HSA, when used for medical expenses, eliminates all 3 of those taxations.
Tax-advantaged accounts such as 401k, 403b, 457, IRA, etc., eliminate the "while you hold the investment" taxes and then either tax #1 (in a "Roth" account) or tax #3 (in a "traditional" account).
Your choice between traditional and Roth should be based on the marginal tax rate you pay now on money you will invest, vs. the marginal tax rate you expect to pay when you withdraw that money and its returns. Comparing spendable amounts, with
P = Pre-tax amount
t1 = Current marginal tax rate
t2 = Marginal tax rate in retirement
i = investment return per year
n = number of years invested
Roth = P * (1 - t1) * (1 + i)^n
Traditional = P * (1 + i)^n * (1 - t2)
So if t1 = t2, your result is identical.
At least, that's the short version. See the following for more arcane details:
http://www.bogleheads.org/forum/viewtopic.php?f=10&t=140758http://forum.mrmoneymustache.com/investor-alley/rolling-over-a-401k/http://forum.mrmoneymustache.com/ask-a-mustachian/case-study-new-job-new-life/http://forum.mrmoneymustache.com/investor-alley/fund-401k-or-roth-ira-first/For more general prioritization, consider:
WHAT0. Establish an emergency fund to your satisfaction
1. Contribute to 401k up to any company match
2. Pay off any debts with interest rates ~5% or more above the 10-year Treasury note yield.
3. Max HSA
4. Max Roth or Traditional IRA based on income level
5. Max 401k (if 401k fees are lower than available in an IRA, swap #4 and #5)
6. Fund mega backdoor Roth if applicable
7. Pay off any debts with interest rates ~3% or more above the 10-year Treasury note yield.
8. Invest in a taxable account with any extra.
WHY0. Give yourself at least enough buffer to avoid worries about bouncing checks
1. Company match rates are likely the highest percent return you can get on your money
2. When the guaranteed return is this high, take it.
3. HSA funds are totally tax free when used for medical expenses, making the HSA better than either traditional or Roth IRAs.
4. Rule of thumb: trad if current marginal rate is 25% or higher; Roth if 10% or lower; flip a coin in between
5. See #4 for choice of traditional or Roth for 401k
6. Applicability depends on the rules for the specific 401k
7. Again, take the risk-free return if high enough
8. Because earnings, even if taxed, are beneficial