Some items the article is glossing over:
First, the rental value doesn't take into account inflation. House payments are fixed, which means it gets effectively cheaper every year. Meanwhile, rents keep increasing. This means that while you can catch a house at the bottom of a bubble and lock in the price, if you rent in that same area, you'll find rents going way up when the housing bubble rises again.
Next, an 800 sq. ft. apartment isn't equivalent to a 1000 sq. ft. house with a yard. If you really want to cheap out on a house, get a mobile home -- though of course that doesn't include land, which is often leased.
Further, in this example, it assumes you have the difference between the two prices free and clear to invest -- you'll certainly need to make sure your investments do well, because at the end of 30 years, you aren't going to be a homeowner, and will still need a place to live.
Not to mention, pets are typically a problem; you're at the mercy of your landlord; the rent can be increased at any time; you have to deal with shared walls with neighbors; and your 6% return is not going to seem very exciting in 5 years when housing picks up again and that $400k house is worth $800k. It WILL pick up -- the country isn't becoming LESS crowded.
Your monthly investment amount will decrease every year as your rent gets increased, meaning your return is not going to be as good as depicted, especially if wages stagnate (as they effectively have in many sectors for the last 8 years). At 5% rent increase per year, you'll eventually be paying around $4000 for that same apartment in 30 years. Around year 20 the apartment costs more per month than the house. (This is a great area, remember, so the demand will be high. In some areas the rent can jump by 20% in a year instead of 5%.) This would mean you'd do significantly worse than if you bought the house.
The basic premise of this article is really "what if you live cheaply and invest your money vs. what if you spend all your money on housing and your house appreciates more slowly than an index fund".
Step 1. Live in your parents' basement for 30 (more) years.
Step 2. Invest the WHOLE $2400 per month on an index fund.
Step 3. Profit!
As you can see, the article ignores things about having your own house that are nice -- like a stable place for people to visit since you don't move every few years to cheaper places; not being at the mercy of parents or landlords; having a yard; not having to obey "quiet hours", and so forth.