The legality of working as a digital nomad is something of a grey area in a lot of cases. Many digital nomads travel on tourist visas which, in many countries, don't permit any form of work. Technically, it's illegal to do any work on these visas. However, it's almost impossible for immigration authorities to identify people who are remote working, so this is rarely policed. Many countries are also happy to let these rules go unenforced because they benefit from digital nomads spending money and boosting the local economy. Digital nomads also rarely ever take jobs away from local people. If anything, they're more likely to even create jobs. However, with the exception of digital nomad visas, immigration rules generally haven't caught up to the (fairly recent) rise of digital nomadism.