I think the fundamental connection that other answers are missing is this:
Given a general-purpose computer (e.g. a CPU), one can program it to perform pretty much any computation that we have defined. However, specialized hardware may perform better, or may not provide any value.
(this answer is focused on desktop processing and uses examples from that domain)
###Replacing software with hardware
If you are old enough to remember PC gaming in the mid-to-late 1990s, you probably remember FPS games like Quake. It started out being "software rendered," meaning the CPU performed the calculations necessary to render the graphics. Meanwhile, the CPU also had to perform input processing, audio processing, AI processing, etc. It was very taxing on the CPU resources. In addition, graphics processing is not well-suited to a mainstream CPU (then or now). It tends to be a very highly parallel task, requiring many more cores than even a modern high-end CPU (8).
We moved graphics processing from software to hardware: enter the 3dfx Voodoo and Nvidia TNT (now GeForce). These were specialized graphics cards that offloaded processing from the CPU to the GPU. Not only did this spread the workload, providing more computing resources to do the same amount of work, the graphics cards were specialized hardware that could render 3D graphics much faster and with more features than the CPU could.
Fast forward to the modern era, and non-CPU graphics are required on the desktop. Even the operating system cannot function without a GPU. It is so important that CPUs actually integrate GPUs now.
###Replacing hardware with software
Back when DVD was brand-new, you could install a DVD drive in your desktop computer. However, the CPUs of the day were not powerful enough to decode the DVD video and audio streams without stuttering. At first, a specialized PCI board was required to perform the decoding. This was specialized hardware that was build specifically to decode the DVD format and nothing else. Much like with 3D graphics, it not only provided more computing resources but was custom-built for the task, making DVD playback smooth.
As CPUs grew much more powerful, it became feasible to decode DVDs "in software," meaning "on a general-purpose computer." Even with a less-efficient processor, it had enough raw speed and pipeline optimizations to make DVD playback work to users' expectations.
We now have CPUs thousands of times as powerful as we had when DVDs were introduced. When Blu-ray came along, we never needed specialized hardware, because general-purpose hardware was more than powerful enough to handle the task.
###Doing both
Modern Intel CPUs have specialized instructions for H.264 encoding and decoding. This is part of a trend where general-purpose CPUs are gaining specialized functions, all in the same chip. We do not need a separate PCI Express board to decode H.264 efficiently as with DVDs early on, because CPUs contain similar circuitry.