OK, so, let's examine that. Let's start with the pendulum (bag) being at the highest point of its arc. It has no momentum, only a certain amount (P1) of potential energy due to gravitation relative to the lowest point of its arc. Now, it begins swinging, converting - due to the force of gravity - that potential energy into kinetic energy, and, as it reaches the lowest point of its arc, it attains its maximum amount (K) of kinetic energy. It then moves against the force of gravity, and its kinetic energy is converted again into potential energy, reaching a maximum amount (P2) at the highest point of its arc on the other side.
Note well: P1 = K = P2.
The total energy of the system is constant. In the absence of any other forces which actually deprive it of energy (air resistance; friction, to which Bart alludes), all that is happening is an endless (perpetual) transfer of potential energy into kinetic energy and then back into potential energy. Gravity is not having any effect on the energy in the system, only on the proportion in which that energy is split between potential and kinetic.