Energy is always shared, whenever possible. No system likes to hold energy. It makes system unstable. That is why water flows downwards, heat is conducted etc. All systems like to decrease their energy, and hence become stable. This is the same reason why in pendulums, the energy transfer happens. Resonance acts as a path to this sharing, like a portal of energy transfer.
The pendulum wants to be at rest, and thus gain stability. Here, the other pendulum is able to take the energy, as they are connected by a elastic string that can transfer the vibrations, the pendulum easily donates the energy to the other. Thus, the pendulum gains partial stability.
Now regarding phase.
Let us start from 1st pendulum. It had a total energy, T, Kinetic energy K and Potential energy,P.
This energy is then shared to pendulum 2.
At max amplitude, T=P, as kinetic energy=0
If both pendulum were at max amplitude together, then at that instant, the sum of their Kinetic energy would be K+K=2K. That means, the total energy is double. This is against law of conservation of energy, as energy is created here.
Due to this law of conservation of energy, they will always be perpendicular , ie, when one is at lowest position, other will be at topmost, such that total energy is always balanced.