I'm not a lawyer. I'm a guy who reads legal stuff on the internet. This is my personal understanding of how it works.
According to all legal precedents, emulation is legal within the
United States. However, unauthorized distribution of copyrighted code
remains illegal, according to both country specific copyright and
international copyright law under the Berne Convention. Obtaining
games through methods not authorized by the developer or publisher is
illegal in the United States.
So in the US, emulation is legal but downloading a copyrighted ROM from a random website is illegal.
If you want to emulate with the maximum amount of legality, you'll have to dump your own ROMs directly from your cartridges. This is much easier to do than it used to be; several people have written guides about building hardware that can be used to read cartridges using an Arduino or Raspberry Pi.
Do you need to destroy your cartridge after dumping it? Here's what the text in a Nintendo pamphlet that accompanied a 3DS cartridge says:
Copying of an Nintendo game is illegal and is strictly prohibited by
domestic and international intellectual property laws.
"Back-up" or "archival" copies are not authorized and are
not necessary to protect your software. Violators will be prosecuted.
So here's the thing. In the US, it's legal to make copies of software in two circumstances. One of them is backup. The other one is if making a copy is an essential step to use the software. Dumping the ROM is an essential step to using it with an emulator, so it seems that you should be legally allowed to own both the dump and the cartridge.
Nintendo can say that they don't authorize making backups, but they're not higher than the law. As long as you don't distribute the ROM dump, they can't prosecute you. But if you sell or give away the cartridge, you should delete your ROM dump of it.
You didn't bring up console BIOS files, but they're salient to the discussion. Wikipedia again:
Under United States law, obtaining a dumped copy of the original
machine's BIOS is legal under the ruling Lewis Galoob Toys, Inc. v.
Nintendo of America, Inc., 964 F.2d 965 (9th Cir. 1992) as fair use as
long as the user obtained a legally purchased copy of the machine.
However, several emulators for platforms such as Game Boy Advance are
capable of running without a BIOS file, using high-level emulation to
simulate BIOS subroutines at a slight cost in emulation accuracy.
The BIOS is the console's copyrighted firmware. The language here is a bit ambiguous ("obtaining a dumped copy"), so I looked at the court case mentioned. The case was about if it was legal for Game Genie to effectively change the way the BIOS worked, not about distributing the BIOS. So I think you'll either have to dump a BIOS off a Game Boy Advance that you own, or use an emulator that doesn't require a BIOS to run.