There are several reasons for compactifying of a space in general. But there are two good reasons in my mind:

To do intersection theory on a space it is good to work with a compact space. For instance, the projective line is a natural compactification of the affine line. you loos loose the information about a point on the affine line via homology: you can move that point to infinity on the projective line, the result on the affine line is the disappearance of the point. So, there is not a well-defined notion of degree for divisors on the affine line. This generalizes easily to higher dimensional cases. We can't prove the Bezout theorem on non-compact spaces since it is not true.

The second reason is more about moduli spaces:

Points on a moduli space correspond to some objects in a category $C$ which are being parametrized by the moduli space. When there is a notion of continuos change of objects of $C$ we get a topology on the moduli space. The moduli space is not compact when it doesn't contain some limits of families of the objects of $C$. So, a compactification should be considered as adding a class of natural limits of the objects of $C$. We get different compactification if we give different interpretation of points on the moduli space. For example $M_{0,5}$, the moduli space of smooth pointed curves of genus zero with 5 points is an open subset of $\mathbb{P}^1 \times \mathbb{P}^1$. Its Deligne-Mumford compactification $\overline{M}{0,5}$, \overline{M}_{0,5}$, which is$\mathbb{P}^1 \times \mathbb{P}^1$blown-up at three points is not just$\mathbb{P}^1 \times \mathbb{P}^1$. The second space doesn't give a flat family of stable curves of genus zero with 5 disjoint sections in the smooth locus of the fibers as an extension of the universal family of curves over$M{0,5}$. M_{0,5}$.

3 added 6 characters in body

There are several reasons for compactifying of a space in general. But there are two good reasons in my mind:

To do intersection theory on a space it is good to work with a compact space. For instance, the projective line is a natural compactification of the affine line. you loos the information about a point on the affine line via homology: you can move that point to infinity on the projective line, the result on the affine line is the disappearance of the point. So, there is not a well-defined notion of degree for divisors on the affine line. This generalizes easily to higher dimensional cases. We can't prove the Bezout theorem on non-compact spaces since it is not true.

The second reason is more about moduli spaces:

Points on a moduli space correspond to some objects in a category $C$ which are being parametrized by the moduli space. When there is a notion of continuos change of objects of $C$ we get a topology on the moduli space. The moduli space is not compact when it doesn't contain some limits of families of the objects of $C$. So, a compactification should be considered as adding a class of natural limits of the objects of $C$. We get different compactification if we give different interpretation of points on the moduli space. For example $M_{0,5}$, the moduli space of smooth pointed curves of genus zero with 5 points is an open subset of $\mathbb{P}^1 \times \mathbb{P}^1$. Its Deligne-Mumford compactification $\overline{M}{0,5}$, which is $\mathbb{P}^1 \times \mathbb{P}^1$ blown-up at three points is not just $\mathbb{P}^1 \times \mathbb{P}^1$. The second space doesn't give a flat family of stable curves of genus zero with 5 disjoint sections in the smooth locus of the fibers as an extension of the universal family of curves over $M{0,5}$.

2 added 67 characters in body; edited body

There are several reasons for compactifying of a space in general. But there are two good reasons in my mind:

To do intersection theory on a space it is good to work with a compact space. For instance, the projective line is a natural compactification of the affine line. you loos the information about a point on the affine line via homology: you can move that point to infinity on the projective line, the result on the affine line is the disappearance of the point. So, there is not a well-defined notion of degree for divisors on the affine line. This generalizes easily to higher dimensional cases. We can't prove the Bezout theorem on non-compact spaces since it is not true.

The second reason is more about moduli spaces:

Points on a moduli space correspond to some objects in a category $C$ which are being parametrized by the moduli space. When there is a notion of continuos change of objects of $C$ we get a topology on the moduli space. The moduli space is not compact when it doesn't contain some limits of families of the objects of $C$. So, a compactification should be considered as adding a class of natural limits of the objects of $C$. We get different compactification if we give different interpretation of points on the moduli space. For example $M_{0,5},$ M_{0,5}$, the moduli space of smooth pointed curves of genus zero with 5 points is an open subset of$\mathbb{P}^1 \times \mathbb{P}^1$. Its Deligne-Mumford compactification$\overline{M}_{0,5}$, \overline{M}{0,5}$, which is $\mathbb{P}^1 \times \mathbb{P}^1$ blown-up at three points is not just $\mathbb{P}^1 \times \mathbb{P}^1$. The second doesn't give a flat family of stable curves of genus zero with 5 disjoint sections in the smooth locus of the fibers . as an extension of the universal family of curves over $M{0,5}$.

1