You need to know the type (retail or OEM) of your license first.
If you bought the Windows boxed, it's retail. You can take it from and to any PC as long as it's installed on only one at the same time. This key SHOULD be backed up, uninstalled from the destination PC, and installed back to the target PC.
If Windows came with the computer or you upgraded that from Windows 7/8/8.1, it's most likely OEM. You can only reinstall it to the same PC (changing disks is fine though), they are most likely fixed to the motherboard, and you should be able to format the first drive, plug the second one in and install Windows on it without even giving a key. It'll sort itself out.
You can check that by going into Settings>Update&Security>Activation. Your licensing status will be right there.
"Windows is activated with a product key"->retail
"Windows is activated with a digital license/tied to a Microsoft account"->OEM
If it is an OEM, your job is way easier. You just need to sign into a Microsoft account on the PC (just to make sure), format that drive, and simply plug the second one in and install Windows on it. It shouldn't even ask for the key. If it does, say "I don't have a key" and it should sort itself out when you connect to Internet.
Warning: if you are changing more than the HDD, the key might become invalid. You will have to go through a call with Microsoft to have it revalidated. It's a pretty quick call though, as long as you say that you did not change your mobo.
as above said, you don't need to worry about licence issues if all you change is the drive its on. Windows has always let you put it on a new hdd, restricting that would be bad as drives were not always reliable in the past. People would have complained if they needed a new licence every time a drive died... I know I would have