I downloaded Windows from Microsoft website. Then I type in (or paste) a product key that I bought from an unofficial seller to activate Windows. Can that lead to any security issues?
No, the product key has nothing to do with the security part of the OS.
If you do not activate a Windows 10 copy, the only practical inconvenient is that you cannot make desktop-related background customization. Everything else work exactly the same.
As for a key brought at a discount, it may very well work and let you activate and use your product on unlimited time or stop working later. In both cases, there no influence on the security part.
But that being said, you should note that owning a product key that works does not mean your software is licensed. The fact that MS does not care is another matter.
It might be illegal, you might (in the Windows license) agree to pay a fine if you enter an invalid product key and be legally held to that, or it might seem to work but later be deactivated if it turned out to be illegitimate, but harming your computer in terms of viruses: not really. There is a super small chance that someone found a buffer overflow vulnerability (or something similar) in the key validator, but I would say that risk is negligible, especially if the key looks normal and is not longer than the key field was designed to hold.