What is the purpose of diodes in parallel with transistors in a solid state relay?
The two diodes within the dotted line represent the bulk parasitic diode in parallel with each MOSFET as per this diagram of a solid state relay (SSR): -




  what do the diodes facing opposite do


When both MOSFETs are activated the MOSFETs will offer low on-resistance and shunt their respective parasitic diodes. You need two back-to-back MOSFETs in a SSR so that you avoid half-wave conduction on AC - that's the problem of having a bulk diode in parallel with a MOSFET.

MOSFETs will operate as switches with a negative supply voltage but this is restricted to about -0.6 volts because of the bulk diode: -



Picture source.

Notice the light blue curve for Vgs at 0 volts (device off) - conduction in reverse (due to the diode) starts at a shade over -0.5 volts but closer to 0 volts the MOSFET can act as a negative voltage switch and has a very similar characteristic when the voltage is positive or negative. So, the back-to-back MOSFET configuration acts as a true AC switch with an on-resistance double that of a single MOSFET. So basically, the diodes are not called into conducting much current at all; when the MOSFETs are off the diodes are blocking and when the MOSFETs are both on, the diodes are shunted by their respective drain source on-resistances.