Why is compactness important to find solution of certain problems? I've been recently re-thinking about my knowledge of compacts sets and I've realized that other than the definition and maybe understanding with some struggle some proofs I don't actually see why they're very important. From some questions in this website which I used as sort of "soft discussion" about the subject it is my understanding that compactness might allow to state if certain functions are bounded or not.
However I came across this question, and I was considering the second answer specifically (more specifically the bit below):

Unlike their Holder cousins, most Sobolev spaces are reflexive Banach
  spaces. Reflexivity is a highly desirable feature for variational
  problems because it gives a little bit of compactness enough so you
  can prove the existence of minimizers (or more general critical
  points) of various energy functionals.

So this made me wonder... Is compactness in general a very highly desirable property that allow to prove existence of solutions of problems in general? If yes, how? I mean what is the general argument that is brought up.
how does knowing that some sets are compacts actually help in proving existence of solutions?
 A: Arnaud gave a link to a very nice post and Song already showed how compactness is used in a minimization problem in the comments. I would like to elaborate a bit more, specifically on the usefulness of compactness in minimization problem in Calculus of Variation.

Many important problems in mathematics and mathematical physics can be cast in the form of minimization problems of some integrals functional, i.e. we want to find $\bar u\in S$ such that
      $$
 \bar u = \min\{ I(u) : u\in S \}
 $$
      where
      $$
 I(u) := \int_\Omega L(x,u(x),\nabla u(x)) \,dx.
 $$
      Here $S$ is some function space, e.g. $S=\{ u\in W^{1,1} : u\vert_{\partial \Omega} = f \}$ for some fixed $f\in W^{1,1}$, and $\Omega$ is a bounded domain in a Euclidean space. The integrand $L$ represents the feature of the problem we want to solve. For example $L$ can represent the energy density for the Dirichlet energy functional or the internal energy of an elastic body.

One method to solve this is called the Direct Method. Suppose that the functional $I$ is bounded below on $S$, we can then choose a minimizing sequence $(u_n)_n \subset S$ such that $I(u_n)\to \inf_S I$. The minimization problem is solved if we can establish the following:

1.) $(u_n)_n$ has a subsequence that converges (in appropriate some sense) to a $u\in S$.
2.) $I(u) \le \liminf_{n\to\infty} I(u_n)$.

The appropriate mode of convergence is usually the weak convergence, since weak compactness is easier to establish than strong compactness. Here we see that compactness is crucial in guaranteeing that $(u_n)_n$ has a convergent subsequence. 
In this case, we want the functional $I$ to be weakly lower semi-continuous in order that the second condition holds.
