"Yes, but how many hours of programmer time did it take to do the optimization, and how much money does a few hours of a programmer's time cost versus a few hours of a single CPU core?"
You seem to be comparing "expensive" optimisation against a single ruin of a programme. How do you think the numbers stack up when the programme is run every day for a year? Maybe it runs multiple instances for different users? Or it's a product you sell and it's run millions of times per day all over the world? So maybe it cost a few grand to optimise, but it saves millions of hours of CPU time around the world making your product that much more competitive than others so you sell more.