The computer pros out there probably already know this. However, I discovered it recently and found it worthwhile to share. The key factors that influence computer temperature (a serious matter for portable devices, such as laptops) are the following (ranked):
1. CPU/GPU usage
2. RAM usage (particularly if your computer ends up using Swap memory)
3. Read/write operations (esp. on slower and/or older modules)
4. Charging (wherever it's applicable)

Beyond these, if the computer is old (5+ years) and worn out, electrical issues on the motherboard may affect temperature too. For example, the soldering may have weakened, or there may be a lot of dust accumulated. Naturally, if the fans aren't working properly, that's a factor to consider too. For laptops specifically, external fans may or may not help, depending on the location of your computer's vents. Sometimes, a laptop stand, providing passive cooling, is enough to help the airflow from the laptop's vents. Cheers