The force by a spring on an object is zero if the spring is relaxed.
In the figure, the left end of the spring is fixed.
The relaxed position of the right end of the spring is called the
equilibrium position, provided that no other forces are applied to the
object.
In the figure, we focus on horizontal forces only, and assume that the friction force is zero. Then the only force on the object in the x direction is the spring force. The spring force acts to return the right end of the spring to its equilibrium position. The strength of the spring force is proportional to the distance that the end must travel to return to its equilibrium position.
The equation summarizes most clearly the nature of the spring force. Note that the - sign ensures that the force always tends to return the spring to its equilibirum length. For the example shown in the figure, the displacement of the end of the spring is in the negative x direction, so that the spring force is in the positive x direction.