There is no "best" time to visit.
Thailand stretches over far more than 1000km from North to South, even with different vegetation zones.
Rain season for me is lovely with all the fresh green and fresh air and lower temperatures/never cold though. Others dislike by getting their shoes wet.
For the North I would avoid Febr-April/May because of extremely unhealthy air caused by fires.