The toy is composed of a puppet set on a wheel which runs on a thin string.
The puppet brings a bar with two very heavy spheres at the ends.
If centre of mass of the system "puppet+bars" is under the supporting point, that is the point of contact between the wheel and the string, then the puppet is in stable equilibrium. If you slightly put the system out of this position, it would spontaneously trend to return to it.
It happens because in this case for the system the weight is a recalling force to the equilibrium position.