Housing stock is a huge thing. As an expat, working remote, and (legally) living here, the locals can't believe how much I spend on rent, which is still cheaper than I was paying in the states, but far more than any native could/would pay.
The country is likely missing out on (pretty substantial) income taxes, so through legalization they are trying to get some of that. I'm sure the countries enjoy the injection of cash into their economy, but they would rather get that from tourists vs. people working, who tend to use more public resources than tourists.