In more detail
Owning has costs beyond the mortgage: property tax, insurance, maintenance, and closing costs both when you buy and when you sell. Renting has the cost of rent, but the money not used for a down payment can be invested. A fair comparison counts the unrecoverable costs on each side: rent for the renter; interest, tax, maintenance, transaction costs and the return given up on the down payment for the owner. Buying usually favours people who stay long enough, often five to seven years or more, for equity and price growth to outweigh the costs of buying and selling.
Why it matters
Comparing rent with the mortgage payment alone is misleading: part of the payment builds equity, while tax, maintenance and interest do not. The answer depends heavily on how long you stay, local price-to-rent levels and interest rates.
Example
A rough rule of thumb puts an owner's yearly unrecoverable costs at about 5% of the home's value (about 1% property tax, 1% maintenance and 3% cost of capital). For a $400,000 home that is 400,000 × 5% / 12 = $1,666.67 a month. If a comparable home rents for $2,000 a month (a price-to-rent ratio of 16.7), buying looks favourable on this test; if it rents for $1,400, renting and investing the difference does.