We need to find the total energy of the system. We have the angle theta that measures the highest swing of the pendulum. At this state where the pendulum changes direction, it reaches a stationary state at its highest point which means that it has zero kinetic energy (KE). Since the energy of the system must remain constant at all times, all the energy must be in the form of potential energy (PE).

I choose the zero of PE to be where the pendulum passes at the bottom of its swing. We need to find 'h', the height above this zero to find the total energy from the definition of potential energy (PE=mgh).
Now we know the height above the zero so we plug it into the definition for PE.
Since the pendulum is at its peak position not moving, the PE equals the total energy of the system.