1) Win 7 / 10 will allow you to install the OS on to a new pc these days, 99% of the time.
Using the license key from the current install. I registered my last copy of Win 10 through a Microsoft account, skipping the prompt to input the license key during Windows install, then registering it with the Microsoft account.
On a future build, I can install Windows again, register that install, and make the install on the old build invalid.
One can also (usually) input the license key. This is not always true, but with a phone call to Windows support, one can usually be ok.
In years past, this was not true, but Microsoft has become much more open-minded about not making you buy so many copies of Windows.
2) When you do transfer a Windows license to a new build, IT WILL NO LONGER BE VALID ON THE OLD PC.
Meaning you cannot use the same single use license on multiple PC's at the same time. Which is fair.
3) When building a new pc, ALWAYS do a fresh install of Windows. Just dropping a hard drive from an old build in to a completely new set of hardware will always cause problems, some not immediately apparent. And can often border on impossible to fix.
4) You can download a Win 10 install media directly from Microsoft, for free, on to a USB stick. Which is imo the best way to do this these days. You can then install this fresh copy of Windows on to the new PC.
It WILL work. If you do not register it, you get an unregistered watermark I believe? And it won't update I think.
But you can get the system up and running before registering.
Which OS do you have currently? And do you have the sticker/license key for that OS?
And do you want the old PC to still be a working registered machine, or are you gutting it for the new build?