I'd say the biggest benefit of staying in one place a long time (and by that I mean 5-7 years, not 20) is that you can see the long-term impact of your architectural choices. IME, developers that have been in one place their entire careers do not have an "immaculate" hold on coding languages, because they've only ever seen one way of using those languages. So you need to balance breadth of experience with understanding what things will and won't make your life (or the life of others after you) easier.
Another thing that is a great reason to stick around is staggered stock grants, (where you get $XK of stock deposited in your account every quarter, just for sticking around, and that amount changes to give you the most encouragement to stay at around 3 years). It's hard to walk away when if you know next month you're due for another windfall (and 2/3 months is the month before or the month of a grant).
The important thing to realize is no matter how you feel about the company, the company probably has no loyalty toward you, and they'll toss you as soon as they don't think they need you.
But yes, there are a few companies out there where you can stay there for 20 years and do quite well. If you hit one of those at the right time and can live with the implications, it's not a bad life.