During simple harmonic motion, energy is interchanged between kinetic and potential energy. As long as there are no energy losses due to frictional forces, the total (mechanical) energy remains constant.
When the kinetic energy is at a maximum, the oscillator is at equilibrium position where it has no elastic potential energy. When the elastic potential energy is at a maximum, the oscillator has reached its maximum displacement (amplitude) so the kinetic energy is 0.
The total energy of an oscillator is given by