We know that a photon can split into an electron-positron pair and that when an electron and positron come into contact they annihilate and produce a photon.
But why does this happen?
As @SK Dash pointed out, the wavefunction of the particle and the antiparticle added together cancel out, and they annihilate to produce energy in the form of photons. Since, in Quantum Field Theory, if you have a phenomena, then it can also happen in the reverse way, so, photons can sometimes produce electron-positron pairs, provided they have an energy of $$E = 2mc^2$$ where $m$ is the rest mass of the electron. The photon must have enough energy to produce at least stationary particles and antiparticles, and since the positron has the same mass as an electron, you get the $2m$.