This is a controversial topic and I am not suggested that this is for everyone, I do not do this myself, however it might be a good strategy for one of you, so I am putting it out there and you can decide for yourself if this is something you might be interested in.
To make this work there are a certain set of conditions that need to be in place, the first one is the ability to take a loan from your 401(k), the rate should be about Prime + 1% which is currently 4.25%, this is fairly standard, next is the ability to have a loan and still contribute to the plan. If you cannot do both at the same time then stop right here, giving up the ability to contribute is irrevocable, any year you don't contribute is a lost year, and you never get it back.
You can borrow up to 50% of the vested account value and the interest you pay back is paid to your account, so how does this work, our assumptions are you can contribute while borrowing, I will use 2013 for calculations as we have a full years’ worth of data. You vested account balance is $20k on 1/2/2013 and the only investment option in your 401k is VFORX which is the Vanguard Target Retirement 2040 Fund. If you invest the full $20k in your 401k in VFORX on 1/2/2013 you will buy 844.59 shares @ 23.68. On 12/26/2013 you will receive a .507 dividend for $428.21 which we will reinvest @ $28.15 for an additional 15.21 shares bringing out total to 859.8 which on 12/31/2013 is worth $24,349.54 (28.32 per share) a 21.75% return.
Now if you were to borrow $10k, and invest it in a taxable account the math would work like this. We will keep the investment simple for the example you can obviously make this as complex as you would like. On 1/2/2013 we buy in 401(k) 422.30 shares, on 12/26/2013 reinvest $214.11 for a 7.61 shares for a total of 429.91 worth $12,175.05 on 12/31/2013. Now the borrowed $10k is used to buy SPY which is a low cost ETF that tracks the S&P 500, buying 68.47 shares @ $146.06. On 3/15/2013 a dividend of $47.52 is paid and reinvested to buy an additional .3 share bringing the total to 68.5. On 6/21/2013 the next dividend of $57.47 reinvested buying another additional .36 shares bringing the total to 68.86 shares. On 9/2/2013 the next dividend of $57.70 reinvested buying another additional .33 shares bringing the total to 69.19 shares.
On 12/20/2013 the next dividend of $67.81 reinvested buying another additional .37 shares bringing the total to 69.56 shares. On 12/31/2013 the total value at shares price $184.69 will be $12,847. Now we have to pay the $425 in interest on the initial loan, so this account value is $12,422 after the interest is repaid plus the $12,175 for total account value of $24,597. You wind up with a final account value of $248 more or a 22.99% return. An extra 1.25% this may not be worth it, for some, for others it might be.
Now there are few holes in this for starters I have not accounted for taxes, based on the sale dates it would be short term capital gains, so at the bare minimum I would wait a few extra days, taxes complicate this a lot as everyone has a unique tax situation so you need to do your own math there. Also you don't have to pay sell the amount that is profit that can be left in the taxable account, so there is flexibility with what to do with the funds. I also used a simple investment example, based on your 401(k) options you might have much worse options in your 401(k) which makes this much more lucrative. Also I simple used SPY outside the 401(k) which is highly risky outside the 401(k) where a more diversified portfolio could provide different results. There is also like in any strategy a risk it could go there other way and you lose more than you would gain so you need to evaluate the strategy and risk aversion to see if this is something you would be interested in doing.
Now before the Face Punches come, I am not suggesting this I am putting the information out there so people can be aware, I do not do this as my current 401k allows for any mutual fund to be purchased in a linked brokerage account, so I manage my vested 401k balance with my other retirement accounts and use a mutual fund the meets my asset allocation needs. Any time you switch jobs I suggest rolling your 401k into an IRA so you can have complete control of your investments.
-Mister FancyPants