The download is free, but the use of it is not
You have to buy Windows 8.1.
It does not come for free to use unless you already have a Retail or OEM license for Windows 8.
Microsoft no longer sells 8/8.1; try amazon.com
Warning:
You do not buy a Product Key by itself, as they are normally stolen/pirated, Volume Licenses which are not for private use, or MSDN keys which are not to be sold by the original subscription holder.
Make sure that you buy the complete sealed package (DVD, license)
https://www.microsoft.com/en-us/howtotell/Shop.aspx
Read Section: Beware of Product Keys sold separately