Yes, El Capitan can run on your iMac. But, there are tasks you need to perform before applying the upgrade, and continuing tasks you need to be doing, no matter which Operating System you are using.
First, for tasks you should be doing on a continuous basis:
1. You need to make frequent backups to an external drive. Time Machine (comes with the Apple OS, and is free) is OK, but a backup/cloning program that makes bootable backups is better. The two best choices are SuperDuper! or Carbon Copy Cloner. Here are links for each of those:
SuperDuper! -
http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html
Carbon Copy Cloner -
https://bombich.com/
2. You need to perform periodic disk cleanup/maintenance/repairs on your internal hard drive. Disk Utility, again comes with the Apple OS and is free) is OK, but again it would be wise to invest in a more robust disk maintenance program like TechTool Pro or Disk Warrior. Here are links for each of those:
TechTool Pro -
https://www.micromat.com/products/techtool-pro
Disk Warrior -
http://www.alsoft.com/DiskWarrior/
There is also an excellent, venerable, and free product called Onyx that is useful. For that one, you need to choose the correct version based on the OS you are using. Here is the link to that fine product:
Onyx -
http://www.titanium.free.fr/onyx.html
Understand that Onyx is
not a replacement for TechTool Pro or Disk Warrior. The tasks it performs are limited, but it is wise to use Onyx in conjunction with either TechTool Pro or Disk Warrior (or even Disk Utility).
3. Keep all third party software you are using up to date. That is so, so critical.
4. Finally, given that the machine is 7 years old, and assuming it contains the original internal hard drive, the drive could go "bad" any time, especially if little, to any, disk maintenance has been performed on the drive. Hard disks typically last 5 to 7 years, even with periodic disk maintenance. So, it's important that you are aware of that. The speed of the internal drive (again assuming it is the original one) is 7200 rpm, which is good. But, if you either want to, or need to, replace it, you can replace the optical drive (the one that takes CDs/DVDs) with an SSD drive. Or, you can just replace the internal hard drive with another 7200 rpm drive.
Now, for the upgrade from Mountain Lion to El Capitan, you will still need to perform 1 through 3 above. You can then upgrade to OS 10.11.3, the latest version of El Capitan. If you do decide to upgrade, when you download the El Capitan file from the App Store, do
not start the upgrade process right away. A file entitled "Install OS X El Capitan" will be in your Applications folder after the download completes. Make a copy of that file somewhere else on your machine. And in fact, make a copy of it on yiur external drive. Once you do that, you can either do an upgrade, or what could be better is a complete Erase and format of your internal drive, then a fresh, clean installation of OS 10.11.3. You would then use Migration Assistant to "migrate"/copy all the needed "stuff" from the external backup.