Technically, it is illegal to do any work inside of Thailand without a work permit and a work-approved visa.
Realistically, as long as you don't advertise that you are doing it, working remotely in Thailand is fine and tons of people do it.
There is no written requirement to be outside of Thailand any amount of time. You can go buy tourist visas every 90 days as long as consulates will continue selling them to you. Eventually the consulates and/or immigration may start questioning why you are spending so much time in Thailand though as a tourist does not usually spend
***
months inside of a country.