Hopefully you left the thermal sensor still connected that was on the optical drive when you pulled it. Review this IFIXIT guide: iMac Intel 20" EMC 2133 and 2210 Optical Drive Replacement jump down to Step 17 which goes into removing it to then put back on the new optical drive. If you didn't leave it plugged in the systems cooling management system (SMC) goes into fail mode pushing the fans to max RPM as it wants to make sure the system is not overheating.
Hopefully you can recover the sensor and put it back in even if you leave the optical drive out. Frankly, I would have just left it alone as now someone will likely drop a disk in without knowing the drive was pulled.
I should also point out there is a similar sensor on the HD which you can see in this guide: iMac Intel 20" EMC 2133 and 2210 Hard Drive Replacement Seen in Steps 18, 19 & 20 that likewise needs to be put back onto the new drive and reconnected as well.