Start with buying one of those Saleaeae clone logic anaysers for EUR 10. (8 ch 24MHz). and use it with Sigrok / Pulseview. It lets you see what is actually happening on the I2C bus, and this determines whether the sender or the receiver has unexpected behavior.
You can use the extra channels to output a debug signal, for example toggle a bit every time an ISR is triggered. This lets you correlate what happens on the I2C bus with what firmware of the uC is doing at that same time.
Another option is something wrong (or even omitting) the I2C pullup resistors (or even the wiring). If the pullup resistors are not strong enough compared to your bus capacitance and bitrate, then you will never get reliable communication.
Beginners also do not always realize both circuits need a common GND for communication to work reliably.
on the slave side it will print the value of 'x'
19:04:10.611 -> x is 51
19:04:11.146 -> x is 52
19:04:11.640 -> x is 53
19:04:12.136 -> x is 54
19:04:12.635 -> x is 55
19:04:13.121 -> x is 56
What do you mean with "does not work"?