Emulators are not illegal, where did you get that from?
It’s required because a lot of the functionality of the PS2 is in the embedded software, the BIOS.
The problem is not the emulator itself, it’s the BIOS which is copyrighted. The emulator is not illegal, but bundling the BIOS with it would be.
If you bundle cryptographic keys, bios or other copyrighted content then yes obviously it’s illegal.
It’s not illegal to implement an emulator.