First, based on the identifier iMac12.1, this is your machine:
Secondly according to that link, that machine came pre-installed with OS 10.6.6, which was Snow Leopard (the last version of that OS was 10.6.8). Also, here is some more OS info (from that link):
"*This system fully supports the last version of OS X 10.8 "Mountain Lion", OS X 10.9 "Mavericks", and OS X 10.11 "Yosemite" except for Power Nap functionality. It also supports the last version of OS X 10.11 "El Capitan" -- including Mac-to-Mac AirDrop and AirPlay Mirroring capability -- but no other advanced features are supported including Metal graphics acceleration. It is capable of running macOS Sierra (10.12) as well, although it does not support the Universal Clipboard, Auto Unlock, or Apple Pay features.
Please note that OS X "Lion" 10.7 and subsequent versions of OS X are not capable
of running Mac OS X apps originally written for the PowerPC processor as these operating systems do not support the "Rosetta" environment. To run PowerPC applications on this Mac, it will be necessary to use Mac OS X 10.6 "Snow Leopard"
Note all the caveats about any OS above 10.11 (Yosemite; I don't know what Power Nap is). And especially note the statements about apps originally written for the PowerPC Processor. If you never
upgraded the OS since you purchased the machine, it looks like you were upgrading from OS 10.6.6 to OS 10.12.1. I am not aware of any actual way of determining what OS you upgraded from, unless it is on an "older" Time Machine Backup. I do not use Time Machine for my backups, preferring SuperDuper!. Maybe someone else can help you better with that.
By the way, when did you purchase the machine, and from which vendor? Directly from Apple?
For disk cleanup/maintenance/repairs, I provided some basics for you. There are a couple of other things you can do which do not require spending any additional funds, but the first thing you need to decide on is which OS you want to get back to. There are some steps you need to take first, though, before beginning such a project. It would be good to know when was the last time you made a backup. And again, you need to tell us what software you used for that.