Many people think that the inside of their computer is a mystical, magical place where complicated things happen that they don't understand. While computers can be complex machines, let's try to understand the hard drive and how it works a little better, so we can understand how and why hard drives fail.
Data is stored on the hard drive in binary form - it is made up of 1s and 0s. The hard drive stores these 1s and 0s as magnetized bits on a metal platter. The magnetic charge of the bit determines if it is a 1 or 0, and thousands of these 1s and 0s make up the individual files that we deal with. In order to be able to access all parts of the metal platter, it spins around very rapidly. A small arm can move across the platter while it is spinning, and reads the data off of it.
Hard drive spins very rapidly (most modern hard drives spin at 7200 revolutions per minute, or RPM). The rapidly moving parts make it easy for something to break and malfunction. Because of the delicacy required, hard drives are built with a lot of precision, and then carefully sealed in their case. However, these parts can still break and fail. Research has shown that if hard drives don't fail within the first six months (because of manufacturer defects), that they will (usually) last at least two years, and then they begin to fail at a rate of 8% a year.
In addition to hardware malfunctions, hard drives can sometimes have software issues. This can be caused by the computer / operating system not writing a file correctly. These are usually easier to repair, as they and be fixed with software.
If you need to recover hard drive data, like a Mac deleted file, then you will probably need data recovery software or in the extreme cases see a hard drive recovery or data recovery specialist. Hard drive recovery companies have lots of special equipment so that they can open hard drives, repair the delicate equipment inside, and then reclose them so that they can be read. You can't open a hard drive and recover hard drive data yourself because you have to have a special clean room environment set up - because the individual bits of data stored on a hard drive are so incredibly small, even a piece of dust can cause some major read issues with a hard drive.
Something like a Windows of Mac deleted file can be recovered much more easily - with data recovery software you can just run some special software which will retrieve the file, if it hasn't been overwritten. There is no real way to delete a file - that portion of the hard drive still exists. Instead, the computer just stops recognizing that those portions of the hard drive are used, and it will overwrite it with another file. If it hasn't yet been overwritten, then it may be possible to recover a deleted file.