The emulator is legal, but once you play a game on it you don't own, its illegal.
Like for instance, if you use a N64 emulator so you can play Goldeneye on it, and you own a cartridge of Goldeneye, you're good. But if you don't own the cartridge and play Goldeneye on the emulator, its illegal.