The Mega has more I/O pins, which might be very useful for something like a MIDI controller, saving the need for I/O expanders.
Well the Teensy 4.1 actually has 55 digital pins (the Mega 2560 has 54 digital pins), but to get to pins 42-54, you will need to solder wires to the solder pads underneath the Teensy, and to use something to bring out the pins in the micro SD card.
The Teensy 4.1 actually has 18 analog input pins (the Mega 2560 has 16 analog input pins) and all of them are easily accessible. So if you need analog inputs for MIDI, the Teensy wins.
The Teensy 4.1 has 8 serial UART ports while the Mega 2560 only has 4.
The Teensy 4.1 can use 35 digital pins as PWM pins (used to rapidly switch ports on/off, to either 'dim' LEDs or control servos) while the Mega 2560 has 15 PWM pins.
The Teensy 4.1 has 8 megabytes of flash memory (minus 64K for system support) while the Mega 2560 has 256K (with 8K reserved for the bootloader).
The Teensy 4.1 has two sets of 512K read/write memories built-in, while the Mega 2560 has 8K. In addition, with the Teensy 4.1, you can solder on one or two 8 megabyte (64 megabit) flash memory chips to the Teensy to give you a lot more read/write memory (but in general, the access will be slower than the main memories). Or you can solder 1 chip for read/write memory and another chip that gives persistent storage (such as you get with a SD card) that you can mount a filesystem on. I use 16 megabyte (128 megabit) persistent flash memory chips on my Teensy 4.1's.
Both have similar sizes for 'EEPROM' persistent memory (4,284 bytes for the Teensy 4.1, 4096 for the Mega 2560). As I mentioned above, you can solder in a persistent memory chip on to the Teensy 4.1 for more space.
The Teensy 4.1 has a built-in micro SD card reader. The Mega 2560 does not, but you can attach a simple SPI micro SD card reader if needed.
The Teensy 4.1 runs on 3.3v, and is NOT tolerant of 5v input. The Mega 2560 runs on 5v.
The Teensy 4.1 runs at clock speeds up to 600Mhz. The Mega 2560 runs at 16Mhz. In addition, since the Mega 2560 is an 8-bit processor, the compiler typically has to issue several instructions to do normal operations, while the Teensy 4.1 can do many of these operations in a single instruction.
The Teensy 4.1 has hardware support for single and double precision floating point. I believe the Mega 2560 uses software emulation.