In hardware, the electrical components get hot due to current running through them.
We don't want the components to be too hot, or they will be damaged.
So we use fans (or liquid cooling) to move room temperature air over the components.
The hot component warms the air, and in turn, the cooler air cools the component.
The warm air is then moved away from the component, and out of the case, and then dissipates into the atmosphere.