On the atomic scale there are two forces of interest. One is simple Coulombic attraction, and the other is a more complicated repulsive force which includes the Pauli exclusion principle and other quantum mechanical effects.
The attractive force can be represented by the potential: $$E_A=\frac{z_1 z_2 e^2}{4 \pi \epsilon_0 r}=-\frac{A}{r}$$
The repulsive force can be approximately represented by the potential: $$E_R=\frac{B}{r^n}$$ where $B$ and $n$ are parameters that depend on the atoms involved and capture the behavior of the QM effects. Often $n\approx 8$
This function, $E(r)=E_A+E_R$ has a minimum at $$r_0=\left( \frac{nB}{A}\right)^{\frac{1}{n-1}}$$ and around that point the potential is $$E(r)=E(r_0+\delta r)=-B(n-1)\left(\frac{nB}{A}\right)^{-\frac{n}{n-1}} + A(n-1)\left(\frac{nB}{A}\right)^{-\frac{3}{n-1}} \delta r^2 + O(\delta r^3)$$
Note that this has the form of the potential for a spring with the spring constant being obtained from the second term.