What CPU to replace ATMega2560?

The RA4M1 processors run at 5V. Unusual for an ARM chip (especially one with floating point hardware), and one of their advantages...

Many sensors use I2C or SPI, which are busses.
Several sensors can share the same two pins.
Port expanders (I2C or SPI) can be used for projects that actually need many pins.
The Mega/Due became sort of obsolete because of that.
Also, more sensors move to 3.3volt-logic.
Leo..

I guess I should also mention the STM32 microcontrollers.

This is a very broad range of ARM chips (all 3.3V) including a bunch with more than 85 IOs. In theory, many or all of them are supported by ST's Arduino core., and Arduino has or had an official board or two based on an STM32 chip. ST has a bunch of "Nucleo" eval boards, some with Arduino Uno pinouts. They used to be pretty attractively priced, but it looks like tariffs have interfered with that :frowning: (they're still not awful.)

However, I don't see a lot of conversation here about these chips/cores, so I don't know how compatible they might be, especially WRT libraries. The chips are relatively well-respected outside of the Arduino community.

And afaik many pins are 5V tolerant...

I like STM32 chips, but I am not sure how well they are supported by Arduino libraries. There is Arduino core, I know.

Don't forget that the new Uno Q has one (STM32U585) together that is, with a Qualcomm Dragonwing microprocessor. https://docs.arduino.cc/hardware/uno-q/

Hmm. The NXP MCXE series of CM4 and CM7 chips has some nice many-pin members, runs at 5V, and up to 160MHz.

But I don't think there is widespread Arduino core support for NXP chips. (The Teensy 3 and 4 are NXP chips, but not the same ones, and I doubt that teensy will directly support the MCXE chips.)