If the iMac will run El Capitan, you can try that.
BUT ... consider yourself as having been duly warned by reading further:
You -may- find that ANY version of the OS (from 10.9 Mavericks and later) runs slower than what you have installed now. The "OS requirements" seem to be more RAM, and most importantly -- a faster drive than the platter-based hard drive the 2007 iMac has.
If you really want to run a "modern" (ok, that's a relative term) OS, you need a modern iMac from which to do so, that has at least a "fusion" drive inside, or more preferably an SSD.
For a 2007 iMac, you might consider 10.8 "Mountain Lion".
Runs pretty fast on older hardware...