Renting is the better option only if you will be moving around in the near future (1-5 years) or if you’re in a dying city. If you’re planning to stay in one location for longer than 5 years (in some hotter markets, even shorter timeframes work), owning your home outperforms renting.
Property taxes, maintenance, and other costs associated with owning don’t go away when you rent, they just get baked into your rent, often at a higher amount. Residential tax rates are typically lower than commercial, which an apartment building would be, and in my city there’s a “residential exemption” for a homeowner’s primary residence which significantly reduces the property tax bill. So even a property that’s taxed at the residential rate is more expensive for a landlord than an owner. Maintenance also tends to be higher for landlords because tenants don’t give a shyt about preventative measures that prevent or lessen the need for future maintenance. Homeowners do. Also, landlords are turning over apartments which necessitates upkeep (such as painting walls) much more often than a homeowner would.
Your landlord is also baking in the risk associated with renting out properties so that they don’t go broke when they need to cover vacancies and problem tenants.
Finally, your landlord’s main objective is to make a profit. If market conditions change (such as a new commuter station gets built within walking distance, or employer bring more higher paying jobs to the area), the landlord may raise rent to not only cover the property tax increase associated with this change, but also maximize your profit. The homeowner’s mortgage is unchanged; their equity just increases. Equity is, of course, the huge benefit of home ownership.