In order for you to qualify for a free copy of windows 10 your previous operating system should be fully updated. This means Windows 7 has to be running SP1 and windows 8 has to be upgraded to 8.1.
If your os meets the above requirements then one can download the Windows 10 upgrade but you must and I repeat must upgrade first. The reason why you have to first upgrade is because Microsoft have changed the way Windows is activated. When your performing the upgrade Windows set up checks an online activation database, which was recently set up by MS, if your os is genuine and activated then a Windows 10 licence is issued and stored in the same place.
This now means that once the upgrade has completed you can perform a clean install and not have to input an activation key. Simply press skip when asked for it.
This will only last for the life of the machine and isn't transferable even if your original licence was retail.
In your case if you simply did a clean install straight away then your key for windows 8 won't work for the reasons I specified above.
You'll need to re-install windows 8, upgrade it to 8.1 then you can upgrade to windows 10 using the process described above.