The math can work out for both renting and owning, you just have to do the math and see which of the two options works for you.
In todays environment homes are so expensive that it can be a questionable investment. At other times in the market that wasn't always the case.