Having a tenant, even paying market rent, will severely depress the value of the building. Yes, SF has "owner move in eviction", but that is a lengthy and costly process and buyers would rather not deal with it, so the value of a place can decrease significantly.
So if you're a landlord with say a 2 unit building, the ideal scenario would be you rent it out, then once you're getting ready to sell, you leave the units empty once tenants leave. Even if you leave them empty for years, you'll get a better return on your investment than if they were occupied by a tenant paying market rate.