يا سلام ...
the reason that the pendulum goes to and fro is the restoring force due to the gravitation... that is ; mgcos theta
As for the period it depends on length of the pendulum as the square root of that length... i.e. it is directly proportional to the length of that pendulum. However; the period is invesely proportional (as the inverse square root) to the gravity and furthermore, it doesn't depend on mass.
is it clear now? I hope so
thanks