I'd imagine that's legal anyway. If it isn't, anyone doing any work, anywhere but in their country of business or employment would be working illegally?
As far as the dtv, it seems you only have to an amount equivalent to 500k in baht and have to have earnt that. Its not stating you need to be employed, or asking for a certain level of income.
I'm not sure why most retirement visa holders wouldn't be better getting this?.