For many years until about a decade ago (more precisely until the launch of the Intel Skylake Server processors) the server CPUs had a performance per dollar comparable to desktop CPUs so the expensive server CPUs were expensive because of their higher performance.

But since then the prices of server CPUs have ballooned and now their performance per dollar is many times worse than for desktop CPUs. Server CPUs have very good performance per watt, but the same performance per watt is achieved with desktop CPUs by underclocking them.

The only advantage of server CPUs is that they aggregate in a single socket the equivalent of many desktop CPUs, including not only the aggregate number of cores, but also the aggregate number of memory channels and the aggregate number of PCIe lanes. Thus a server computer becomes equivalent with a cluster of desktop computers that would be interconnected by network interfaces much faster than the typically available Ethernet links.

While for embarrassingly parallel tasks a server computer will cost many times more than a cluster of desktop computers with the same performance, it will have a much less disadvantage or it might even have a better performance/cost ratio for tasks with a lot of interprocess/interthread communication, where the tight coupling between the many cores hosted by the same socket ensures a lower latency and a higher throughput for such communication.

The owners of datacenters are willing to pay the much higher prices of modern server CPUs because the consolidation into a single server of multiple old servers brings economies in other components, due to less coolers, less power supplies, less racks, simpler maintenance and administration, etc.

While the prices of server CPUs at retail are huge, the biggest costumers, like cloud owners, can get very large discounts, so for them the difference in comparison with desktop CPUs is not as great as for SMEs and individuals. The large discounts that Intel was forced to accept during the last few years, to avoid losing too much of the market to AMD, were the cause why Intel's server CPU division has lost many billions of $.