Hooke's Law
Hooke’s law defines the linear relationship between the force applied to a spring and its displacement from the equilibrium position. Due to Newton's third law, the force that has to be applied to a spring in order to stretch (or compress) it for a certain amount x is equal and opposite to the restoring elastic force exerted by the spring when it is stretched (or compressed) of that amount.
This means that if you attach a mass to a spring (Figure 1) and you displace it from the spring equilibrium position x=0, the spring will exert a restoring force on the mass that, for small displacements, obeys Hooke's law. The larger the displacement, the larger the elastic force acting on the mass to bring it back to equilibrium. Typically, Hooke's Law is written in the following form:
Where F is the spring elastic restoring force, k is the spring constant and x is the displacement (distance from the spring equilibrium position), sometimes also called extension (or compression). The negative sign means that the spring elastic force is always opposite to the displacement direction (i.e. it always points towards the equilibrium position of the spring).
Figure 1: Horizontal Spring
In the case of a horizontal mass-spring system in the absence of friction, the total force acting on the mass is equal to the elastic force just defined by Hooke's Law. This is precisely the type of restoring force that gives rise to a Simple Harmonic Motion.
Note that Hooke's Law is an empirical law which is only approximately obeyed in real-world cases. However, it works extremely well for small displacements or idealized model systems where the force applied to a system and the resulting deformation (stretch, displacement) are linearly proportional. It is therefore not limited to springs, but it describes any linear elastic deformation.