Damped Oscillation and Resonance
Here we talk about oscillation especially damped one and how resonance occurs in an oscillating system. You'll get an idea that everything has its own oscillating frequency, called natural frequency. It is the kind of frequency that an object shows when it oscillates without any kind of external force.
Damped Oscillation
When a body is left to oscillate itself after displacing, the body oscillates in its own natural frequency. Let that natural frequency be denoted by $\omega _n$. But the amplitude of the oscillation decreases continuously and the oscillation stops after some time.
The decrease in amplitude is caused by the non-conservative forces such as friction in the system of the oscillation. The non-conservative forces are also called dissipative forces.
In real life situations the dissipative forces do work on the oscillating systems and the oscillations die out after some time and such oscillations are called damped oscillations.
In Figure 1 from simple harmonic motion you can see a mass-spring system in which a box oscillates about its equilibrium position.
If the friction between the surface of the box and the floor is not neglected, the oscillations die out after some time. The force that causes damping of the oscillation is called damping force. The restoring force provided by the spring is
\[F_\text{spring} = - kx\]
Here we consider the simpler case of velocity dependent damping force. The expression for the damping force is,
\[{F_{dx}} = -b{v_x} \tag{1} \label{1}\]
The negative sign in the above equation shows that the damping force opposes the oscillation and $b$ is the proportionality constant called damping constant. We consider that such a damping force is along x-axis as indicated by the subscript $x$.
Therefore, the net force on the harmonic oscillator including the damping force is,
\[\begin{align*} {F_{{\rm{net}}}} &= - kx - b{v_x}\\ {\rm{or,}}\quad m{a_x} &= - kx - b{v_x}\\ {\rm{or,}}\quad m\frac{{{d^2}x}}{{d{t^2}}} &= - kx - b\frac{{dx}}{{dt}} \tag{2} \label{2} \end{align*}\]
We do not go into solving Eq. \eqref{2} (but you can go ahead and solve it), the solution is,
\[x = A{e^{ - bt/2m}}\cos (\omega t + \phi ) \tag{3} \label{3}\]
In Eq. \eqref{3} the amplitude of the damped oscillation is $A' = A{e^{ - bt/2m}}$ which decreases exponentially with time (see Figure 1).

In Eq. \eqref{3} the angular frequency of the damped oscillation is $\omega = \sqrt {\frac{k}{m} - \frac{{{b^2}}}{{4{m^2}}}} $. We apply a condition that when $\omega = 0$, you'll get,
\[\begin{align*} \frac{k}{m} - \frac{{{b^2}}}{{4{m^2}}} &= 0\\ {\rm{or,}}{\kern 1pt} \quad b &= 2\sqrt {km} \tag{4} \label{4} \end{align*}\]
When the value of the damping constant is equal to $2\sqrt {km} $ that is, $b = 2\sqrt {km} $, the damping is called critical damping and the system is said to be critically damped. In critical damping an oscillator comes to its equilibrium position without oscillation.
And when $b < 2\sqrt {km}$ the system is said to be under-damped and the damping is called under-damping. In under-damped oscillating system the oscillator oscillates but the amplitude of the oscillation decreases continuously and finally the oscillations stop.
In another case when $b > 2\sqrt {km} $ the oscillating system is over-damped and the damping is called over-damping. In over-damped case the oscillator comes more slowly to its equilibrium position without oscillating.
Resonance
Every object can oscillate about its equilibrium position when displaced by an external force. When a particular body is displaced from its equilibrium position, the body starts oscillating with its own natural frequency $\omega _\text{n}$.
If you apply an external periodically varying driving force on the oscillator, you can change the frequency of the oscillating body in your need called driving frequency $\omega_d$. And the corresponding periodically varying force is called driving force.
When the natural frequency of the oscillator is equal to the driving frequency of the external force, the amplitude of the resultant oscillation increases dramatically.
The effect of the largest amplitude peak obtained when $\omega_d$ equals $\omega_n$ is a phenomenon called resonance.

In Figure 2 you can see how the amplitude of a forced oscillation increases when the frequency of an external force nears the natural frequency of the oscillator.
In Figure 2 you can also see different curves for the same oscillator for different damping forces - greater the damping force, lower the amplitude at resonance. In curve $a$ the damping force is lesser than the damping force in curve $b$. And in curve $b$ the damping force is lesser than the damping force in curve $c$.
That's the reason why solders are said to stop marching while crossing a bridge to avoid destructive effect. The reason is that when the solders march over a bridge, the driving frequency of their marching may nearly equal to the natural frequency of the bridge and the bridge can oscillate with the greatest amplitude possible due to the phenomenon of resonane which can destroy the bridge.