Welcome to flyertalk, Tokar!
Airline fares are typically not set based on actual costs, they are set based on supply vs demand. So you get strange differences like this one. Whether or not you can make a stopover in Japan (usually for an extra fee) depends on the fare rules, which you'd have to look up.
Note that if you miss a single segment of a flight all on one ticket, the rest of the ticket is canceled. So even if the Bangkok fare allowed a stopover in Japan, you'd still have to go to and from Bangkok.