From a technical standpoint, the PS5 is more then powerful enough to properly emulate PS1, PS2, PS3 (going by RPCS3) and is architecturally extremely compatible with the PS4. The only reason the PS4 might be an issue is that the PS5 will probably use a newer version of FreeBSD (and thus newer, incompatible software libraries). But there are multiple software container platforms that can package the older PS4 libraries for the games to interface with.
Will Sony do this? I somewhat doubt this, and not because they really want you to buy these games again. Veryfying the massive library from the PS1 -> PS4 might simply be impossible and there is always the possability some strange edge case game won't run or will do so poorly. Sony probably doesn't want people to experience a bad case of emulation.
A solution might be something like Steam Play and Proton, where Windows games can run on Linux. Normally, you can only run games verified by Valve to work on Linux. But you can quite easily by searching a menu turn on Proton for ALL Windows games (of course not all games run perfectly on Proton). Sourcing emulators is always a legal minefield, but since Sony build the consoles being emulated, they could work with existing emulators to make their games run.