Arduino mega with esp32

Both the ESP32 and the Mega/w5500 could, I suppose, use IP to to talk to each other. Or are you not using the WLAN functionality of the ESP32 ?
Anyway, if you want to use Serial/UART, both the Mega and the ESP32 have multiple hardware serial ports over which they could exchange data. It is quite simple and you could start with this tutorial: Serial Input Basics - updated
The TX pin of the Mega should have a voltage divider to present a maximum of 3.3 volts to the RX pin of the ESP32. The other direction is not so critical but you should also consider a proper 3.3v/5v level shifter.