New computers generally come with an operating system, probably Windows 10. So once you have started up and run the new machine it will be licenced with MS. Your old machine running W10 on an SSD is of course licenced.
So licence wise, yes. The problem may be that your old drive will have incompatible chipset drivers and may just not run at all...or it may just work fine or have random glitches. I presume that you want to do this so that you don't have to move all your applications and data.
What may work would be: To make a USB stick of W10. Put the old disk into the new machine and then do a full load of W10 from the USB stick selecting to keep all apps and data. A good chance this will sort out any chipset problems and get the drivers for new network and video cards.
I hope someone else will enter this thread as they may have better advice.... I wouldn't do it personally.