The answer is: Homes have the potential to appreciate in value over time
This mean that if you buy a home, you would most likely to obtain your investment back in the future and Since there is no change in ownership when you rent a home, you would not gain any profit if the home increase in value.
Because of this, if you are planning to stay in that home/area for a long time, it is more profitable to purchase it. But if you are planning to stay only for a short period of time, it is more profitable to rent it.