It’s quite easy to find games (roms) on the internet, but is downloading them and installing them to your retro handheld, Raspberry Pi or other emulation device legal? The answer is not easy and nothing here constitutes legal advice, only an opinion. Also countries outside of the USA may have different laws and regulations. Therefore, you should research the question according to local laws.
Emulators are the code that can interpret the game files (i.e. roms, bios, etc.) and run the game. Emulators typically do not include the BIOS or the firmware used to perform hardware initialization, runtime services and programs needed to emulate the given game. Therefore, emulators themselves are typically legal. If a specific emulator contained the BIOS image within the archive, this could be challenged. 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.
Emulators are not helpful without ROMs and ROMs are often unauthorized copies of copyrighted material. ROMs are the game files themselves. In the US, copyrights are protected for 75 years. Therefore no games will be in the public domain for quite sometime. That is unless the author has released them into the public domain, some examples of legal ROMs but may only be distributed only by the stated page.
There are possible untested exceptions, Fair Use, for example. Keep in mind, downloading a game you don’t own is never legal. But what does this mean? I’ve purchased many digital copies of games on various consoles, such as the Wii, Android and others. I own several original consoles, re-released licensed consoles, original cartridges, original arcade machines, mini-arcades/consoles, etc. Is it legally defensible that by downloading those games to play on a modern console/handheld is legal? There may be a legal defense for fair use if you already own a downloaded game, purchased the game and downloaded it as a backup. But even this isn’t black and white, it’s just an argument. This is a grey area and hasn’t been tested in court.
Sharing ROMs on the internet for others to download is certainly illegal. You will never see download links for roms, rom sites or romsets on this website. It is up to you to backup your own games, or locate backups of games that you personally own. I hope this helped some. Again, the above is just an opinion and certainly not legal advice.