I bought a computer with Windows, and I am currently dual-booting Windows and Linux. I would like to remove Windows from the computer itself and install it in a virtual machine (VM) in Linux using the OEM activation key. Is this legal?
It is, if the terms of the license allow you to do so. That means (1) it is not categorically illegal to transfer software to a new machine (in any sense of "machine") and (2) it is not universally allowed. OEM licenses are not generally transferable to a "new machine", and there are technical aspects that prevent you from illegally transferring the OS from one machine to another. It would also be illegal to thwart those technological safeguards that prevent copying without permission (infringement).
The license terms might not be crystal clear as to what constitutes "the machine" for which the license is valid. I assume that you didn't change the motherboard. Then the question would be, what clause in the license agreement clearly forbids installing Windows on a virtual machine under another operating system? This version of the license does not appear to impose any restrictions on installation under a virtual machine, other that the requirement to install on only one virtual machine.