Here you will find instructions on how to root various Android devices and emulators.
If you’re trying to decide which emulator to run, I highly recommend Nox. It has much less “bloatware” (extra apps and useless features you don’t need) than Bluestacks, it's 100% free (recently Bluestacks has gone to a “freemium” model) and it's much easier to root (in fact, root support is built-in and only requires turning on one setting.) Also Nox seems more stable and faster than Memu (in my personal experience, Memu crashes/does weird things with SIF somewhat often.) It is the only emulator that I have gotten Xposed Framework to install on. Finally Nox is also cross-platform, available for both Windows and Mac.
If your device or emulator is not listed here, your best bet is to search the XDA Developers forums for a forum about your specific device or emulator, and you will probably find instructions on how to root it there.