The diodes rectify the line voltage, meaning that you can't get the phone line wires back-to-front.
The transistors and optocoupler form an off-hook detector -- when the line voltage drops below the vicinity of 15V, the leftmost transistor turns off, allowing the transistor driving the optocoupler to conduct. The opto coupler then passes the signal to the microcontroller. There might even be breakthrough when the phone rings due to the high ring voltage being above the BC547 blocking voltage.
The MT8870 is a DTMF receiver/decoder. It is fed audio from the phone line and if a valid DTMF tone is detected, it passes the decoded key number to the microcontroller.