I have connecting flight via 21 hrs transit in Bangkok. Will Thai Airways provide free accommodation for transit in Bangkok?
No. Thai Air does not provide transit accommodation even if you are in international first class. Also, their lounges in Suvarnabhumi Airport are closed in the wee hours (02:00 - 05:00).
There are many inexpensive (less than USD$35) hotels with free 24h shuttles close to the airport. My wife and I have used this option several times. I suggest you look at sites like agoda.com or sawasdee.com and find an airport motel. A 21 hour layover is plenty of time to get to a nearby motel, check in, sleep (deeply), and get back for your next flight.
If you don't want to clear immigration, you can check out Louis's Tavern airside rooms.
I know these options are not free. The only free option is sleeping in the airport; there are places with reclining seats, but even these will get old after 21 hours (IMO).