Yes, RetroArch is legal. Emulators themselves are completely legal as they don’t have any proprietary code and do not violate any copyright laws.