The best overall time for visiting most of Thailand vis-a-vis climate falls between November and March - during these months it rains least and is not so hot. Remember that temperatures are more even in the south, so the south makes a good refuge when the rest of Thailand is miserably hot (April to June). The north is best from mid-November to early December or in February when it begins warming up again. If you're spending time in Bangkok, be prepared to roast n April and do some flood-water wading in October - probably the two worst months, weather-wise, for visiting the capital.
The peak months for tourist visitation are August, November, December, February, and March, with secondary peak months in January and July. You should consider travelling during the least crowed months (April, May, June, September and October) if your main objective is to avoid vacationers and to take advantage of discounted rooms and other low-season rates. On the other hand it's not difficult to leave the crowds behind, even during peak months, if you simply avoid some of the most popular destinations (eg Chiang Mai and all islands and beaches).