People haven't stopped using mainframes. In fact sales of mainframes have been growing at a very healthy clip.
That said, commodity hardware is a lot cheaper than niche hardware due to increased competition and economies of scale. So any problem that can reasonably be tackled on commodity hardware is generally cheaper to do so.
However not all problems are a good fit for commodity hardware. Mainframes win if you need reliability guarantees, and win again for sustained high volume IO. Commodity hardware doesn't keep up. Similarly there are computational problems that require a lot of IO and communication between the processing nodes. Supercomputers beat clusters of commodity hardware for those problems.
But if you've got a computational problem and it doesn't fall into one of those narrow categories, commodity hardware will be cheaper.
So why did people stop using mainframes again?