One of the 'burning'
questions that I'm suprised nobody has asked is "how old is your iMac?"
If it's new or less than a 2-3 years old it should be pretty clean inside. If older and subject to your environment you may have fans that are partially blocked and unable to supply essential cooling air to the CPU/GPU.
I have a mid 2010 27" iMac, and 5 years ago when I first opened it up to install an SSD, I was horrified to see the amount of clogged dust/debris in all the fans (all the more surprised as my wife keeps the home near spotless). Prior to that I'd felt that the iMac was getting pretty warm at the top (which is where the hot air exits from), but it had always performed well. As it was 5 years old at the time, I completely disassembled it for refurbish, cleaning/re-pasting the CPU, and thoroughly cleaning the 3 fans and re-lubing the spindles. With a 500GB Samsung SSD installed and RAM added to a total of 12GB the iMac was truly transformed, and it's still in regular daily use today. I cleaned the fans again last year. It's still an excellent performer.
What model of iMac do you have? It may just require a spring-clean.......