The conventional wisdom states that any money you put into your mortgage is going towards something that you will eventually own, while any money that you pay in rent is money that you are giving away to somebody else.  If you buy a house, then at the end of 30 years (or whatever your mortgage term is) you will own an asset.  If you rent for 30 years, at the end of 30 years you won't have anything more than you started with.

The conventional wisdom overlooks the glaring fact that there are expenses associated with owning a house that a renter doesn't have, most obviously taxes and maintenance.  So all of the money that a renter isn't spending on their house, they could be investing.  At the end of the time that they would have paid off their hypothetical mortgage, they could have accumulated a healthy investment account.

Whether a renter will be able to make more money than a homeowner depends on a number of factors, some of which you can know in advance (e.g. property tax rates) and some of which you can't (e.g. future property values, future stock market performance).  But broadly speaking, if you expect property values in an area to increase in value more than whatever you would be investing your extra money in otherwise, then buying will have a higher return.

Over the long run, property values have historically outperformed most other investments (although this is likely 'conventional wisdom' as well - see comment).  However, there are obvious cases where this is not true, both in isolated geographic areas (Detroit, for example) and in short time periods (the years around 2008).

In short (and leaving aside some of the more personal factors discussed in other answers) if the property values in the area you will be living in are stagnant or declining, and you expect them to remain that way for much of the time that you will be living there, then renting may be a better option financially.  If you expect property values to increase, then buying is probably better.