When electrical devices such as computers operate the electrical resistance causes heat which needs to be removed. There are three ways to transfer heat: conduction, convection and radiation. The components with electrical resistance such as resistors and inductors radiate heat from the component to the air and several components with higher wattage ratings are mounted on a metal platform which increases the component's surface area to also effectively transfer heat into the air.
The heated air inside the computer housing needs to be removed faster than it builds up. Too much heat can damage circuitry or cause the electrolyte chemicals in capacitors to expand and possibly explode. When the computer is idle usually the holes in the housing are enough to ventilate the heat. When the computer becomes active and too much heat builds up a sensor will switch the cooling fans of the computer on. If the sensor can't switch the fans on at a certain temperature point the sensor will then cause the computer to shut down to prevent heat damage.
Some more expensive computer models use liquid cooling rather than fans to remove excessive heat.
The main function of a computer fan is to remove heat and replace it with fresh air into the system. This cooling fan has been designed to be suitably placed on the motherboard or hard disk drive. There are about 3 or 4 fan blades on the CPU.
There are also computers that have been specifically designed to have an extra fan attached to a computer case made of aluminum, however, the fan is not enough to reduce the heat generated by the CPU so the CPU cooling fan must be installed, especially for computers that are used between 12 up to 15 hours a day so that the fan will not be enough to provide adequate air ventilation. Therefore the cooling fan for the CPU is designed and has been proven to be able to reduce heat generated by the CPU even though the computer is operated for a long time.
The secret to this question lies within the question itself.
Cooling fans simply cool the essential, heat producing components of a computer.
And if you are curious as to why this is necessary, simply put, heat destroys components once the temperature reaches a certain point. The temperature of catastrophic failure can vary from component to component, and vary with different architectures, and brands, but the theme resonates the same with all components. A safe, operable temperature must be maintained for a computer to function properly, and without components to cool a computer, most systems will inevitably overheat.
The cooling fans on a computer are in place to keep the internal components cool and to promote airflow within the case. Many electronic components run very hot. For example when you place that many transistors so close together on a CPU chip the resulting heat can be immense. Having fans in your computer to ensure that everything keeps cool will allow your computer to continue running smoothly.
The resistance in the circuit board electronics creates a great amount of heat so the fan is there to cool it down. Without the fan the computer would most likely catch on fire or melt down to the point of no longer being useable.