You want bonds if you want less risk. The market outperforms them historically yes, but they're less volatile. Your stocks can lose 30% of their value over a week. Bonds will only drop a little bit when they drop. So as you get older and retire, a giant loss will be catastrophic. By using bonds, you're basically saying you're OK with capping your possible gains because you'll actually need the money soon.
I've been going by a bond allocation of 120-(my age). I'm 30 now, so I'm at 90% stocks 10% bonds, and even then I'm only using that for a little bit of diversification. Since I'm ignoring my retirement funds for a long time (I figure 10-15 years is the LEAST I'll continue working), all I are about is long term growth.
Having that 10% allows me to annually rebalance, so it'll force me to sell high and buy low. If stocks continue to drastically outperform bonds this year (bonds have lost me money, stocks have had a small gain), then I'll finish the year at something like 93% stocks and 7% bonds. I'll be 31 when I rebalance, so I'd sell 4% of the stocks to buy bonds. That'll be "locking in" the gain I made, because stocks will be at a high point and bonds a low point.
Realistically I'll have even a higher percentage in stocks, because my 401k right now is currently thrown 100% at stocks and bonds just make up a tiny chunk of my IRA. So my year-end percentage will probably be maybe 96% stocks, 4% bonds just based on my contributions throughout the year before rebalance.