Integration by substitution, or $u$-substitution,
is the most common technique of finding an antiderivative.
It allows us to find the antiderivative of a function by reversing
the chain rule. To see how it works, consider the following
example.

Let $f(x)=(x^2-2)^8$. Then $f'(x)=8(x^2-2)^7(2x)$ by
the chain rule. Remember that we have the "inside part"
$(x^2 -2)$, and its derivative $(2x)$. We can use this
knowledge to antidifferentiate, if we have an integrand that has
an "inside part" and is multiplied by the derivative of that
"inside part".

To see this, consider $\int 8(x^2-2)^7(2x)\,dx$. We make a
substitution to make it clear what to do: Let $u$ be the inside part, so $u=x^2-2$. We differentiate $u$,
and use the notation $du=2x\,dx$
(instead of $\frac{du}{dx}=2x$; you will see why when we subsitute
back into the integrand). Then $\int 8(x^2-2)^7(2x)\,dx=\int
8u^7\,du$ by directly replacing every
element in the first integrand, including the $dx$,
by exactly what it becomes via the substution (in
blue above). This
integral is now easy to evaluate, giving $u^8+c=(x^2-2)^8+c$.

Notice our integrand above was a composite function, $f(g(x))$
where $g(x)=x^2-2$ was the inside part. This $u$-substitution process can be
stated formally as shown below. Notice that the first
integrand is a composite function multiplied by the derivative of
the inside part.

$$ \int
f(g(x))g'(x)\,dx = \int f(u)\,du.$$

Another example:

$\displaystyle \int \cos(x^3)\cdot 3x^2\,dx\overset{\fbox{$
\,\,u\,=\,x^3,\\ du\,=\,3x^2\,dx$}\\}{=}\int \cos(u)\,du=
\sin(u)+c=\sin(x^3)+c$. Do:
Differentiate to check this answer!

By choosing a suitable function $u$, we can often convert hard
integrals into much easier integrals that we know how to evaluate.
Unfortunately, there is no magic formula for deciding what $u$
should be — this is a toolkit, not a recipe. Some examples
are in the video that follows.