Whenever a body is displaced a little from its equilibrium position(main position) a restoring force act on the body in the direction opposite to its displacement in order to bring the body back to its equilibrium position.
This restoring force is proportional to the displacement, provided the displacement is small. If the body is left their, it returns back to its mean position, under the restoring force.
The body gains some kinetic energy which helps to overshoot its mean position and body goes to other side, Again, a restoring force is setup which shows it down and brings the body back to the mean position and so on.
In this way the restoring force help in oscillating the body back and forth about the mean position with a definite period.
Now from Newton second law of motion
F = ma
For a body executing SHM we have earlier know that
Thus we can define SHM in other way
It state that simple harmonic motion is the motion executed by a particle subjected to a force, which is proportional to the displacement of the particle and is always directed toward the mean position.