iOS operating systems are legally available free directly from Apple's support site. More importantly, there is no need for key codes. Download the image, use DiskMaker X to make a bootable DVD/USB/FireWire/ThunderBolt drive or even an SD card will suffice, and install the operating system.

The process is easier than installing any of the Windows operating system versions for PC laptops, as all the drivers are natively supported, and the actual software is free for all Mac's (PSA: for Hackintosh installs...please buy a legal copy of the iOS version).

I couldn't get any OS for my macbook until I took it to the apple store. My macbook would only take a certain OS (el Capitan) and it wasnt available for download anymore. I legitimately had to take it to Apple to get the OS installed because it would not download upon setup for me.