We can often cast enumerative geometry questions in terms of intersection theory in some moduli space. To make this work, one needs to have something like a fundamental class for the moduli space. To get something like a fundamental class one usually tries to find a nice (geometrically meaningful) compactification. Then, pairing against the fundamental class is computed by integrating over the whole space - and there you see why it is important/useful to have a compact space.
A nice elementary example of the benefits of compactifying is provided by Bezout's theorem on counting the intersections of curves in $P^2$. It says that the number of intersection points (counted with multiplicity) is equal to the product of the degrees. If you instead try to work with curves in affine space $A^2$ then it is more complicated to count the intersection points. In this example, I am thinking of $A^2 \subset P^2$ as a simple example of compactifying a moduli space.
I don't know the details of this one, but I recall that the irreducibility of the moduli space of curves in any characteristic was proven by Deligne and Mumford via the introduction of the famous Deligne-Mumford compactification.