A mortgage doesn’t make money, but it (can) enable spending less money. If you buy a place such that interest, maintenance, insurance, taxes and the opportunity cost of not being able to easily relocate are less than rent, then you have saved the difference.
It’s also a way to force saving, which is psychologically useful (and thus valuable).
It’s also a way to force saving, which is psychologically useful (and thus valuable).