If you're only going to sleep for 4 or 5 hours, and if you're on an international-to-international transfer on one ticket, then leaving the airport will mean passport control x 2, plus likely paying the 700THB airport fee per passenger, plus time to get to the hotel. Not worth it for me. The dayrooms are pretty basic, and overpriced for what they are, but for only 4 hours, I'd say they're likely the best choice.
For longer transits, if you're going to sleep for 6-8 hours and/or want to do something besides staying in an airport, then I recommend getting a room in the city, provided your arrival/departure times are well outside rush-hour times. Taxis to many parts of the city take under 30 minutes each way, and cheap rooms are to be had all over the city. I know the cheap hotels nearby the airport have their supporters, but I recently recommended a Thai friend stay in one of the most highly recommended of those places, because he was looking for something cheap. He hated it and said never again. It was too noisy with planes overhead, and noisy guests, and he said it was nothing but a cheap overpriced guesthouse. I was quite surprised being he's not very picky and stayed at many guesthouses in the past, so I thought one recommended by so many farangs would be fine for him. He told me next time he'll just get a hotel in the city, which might be slightly more expensive, but much nicer. Not trying to belittle anyone's opinion of staying in one of these guesthouses near the airport, but just offering an alternate view that for some they're not really a bargain.