Customs and immigrations everywhere provide official processes people can follow for living and working in a country. Enforcing this stuff happens on a country-by-country basis and detecting it can be slow and difficult or not even close to a priority but that does not make it a gray area. Here in Costa Rica they've made many steps in the last few years to address "perpetual tourism", it used to be easy to live here on renewable tourist visas and many people took advantage of that.
http://blog.therealcostarica.com/2009/08/13/the-new-costa-ri...