The links provided in this previous answer are now broken. Mojang have updated their website to redirect to Minecraft.net - but you can still access your Mojang account using the link at: http://account.mojang.com/login
Here's a guide from Mojang support: https://help.minecraft.net/hc/en-us/articles/360035130391-Minecraft-for-Windows-10
Players who have purchased Minecraft: Java Edition before October
19th, 2018 can get Minecraft for Windows 10 for free by visiting their
Mojang account. Log into account.mojang.com, and under the “My Games”
heading you will find a button to claim your gift code. If you
purchased Minecraft: Java Edition after October 19th, 2018, the button
will not be there, so if you’re unsure of when you purchased
Minecraft: Java Edition, that’s a good way to check. Pressing the
button will generate a token and send you to a Microsoft redemption
page.
If you have an older Minecraft account (you still log in with your
username), visit this article to find out about account migration.
Once you’ve migrated your account, you will be able to claim a code
for Minecraft for Windows 10.
You must be signed into a Microsoft/Xbox Live account in order to
redeem the code. Please note that you cannot move the license once the
code has been redeemed. Your code is saved on your Mojang account page
for future reference.