If you're taking one hard drive out of a laptop and putting a new one (or old one, in this case, that happens to be better) in, that is perfectly legal. If, for example, the laptop has a Windows 7 Home Premium COA on the bottom, you can use that key to activate that install of Windows 7. What you cannot do, however, is use one from another computer.
For instance, if your laptop has a Windows Vista COA on it, you cannot use another COA OEM key from a Windows 7 laptop that you don't use anymore to install and activate Windows 7 on that laptop. Sorry, but that's not what you paid for.
The comparison would be this: Imagine that you own a junk yard, like the ones people drop their busted up cars at. Someone leaves a busted up Honda Civic there, and you take possession. As a junk car, you do not need to insure or register it. Your daily driver is a Corvette Stingray. While you can't drive the aforementioned Civic, it stays there, something dawns on you: you can claim it as your daily driver instead of the Stingray and save a ton of money on your car insurance! Guess what, you can't, because that's illegal (insurance fraud).