I was reading the chapter about isoperimetric inequalities in DaCorogna's book "Introduction to The Calculus of Variations". The isoperimetric inequality is proved to be equivalent to Wirtinger Inequality. At page 154, he introduces Wirtinger inequality in this way:
Let $$X=\{u \in W^{1,2} : u(-1)=u(1) \ \ \text{and} \ \ \int_{-1}^1 u(x) \, dx = 0\}$$. Then $$\int_{-1}^{1} u^{'\, 2} \, dx \geq \pi^2 \int_{-1}^{1} u^2 \, dx, \ \forall \, u \in X.$$
I'm new to Sobolev spaces and my question is: why, exactly, the need to introduce Sobolev space as the $X$ of choice?
You don't need to introduce Sobolev spaces, but the point here is that $W^{1,2}$ is the completion of $C^\infty$ with the norm $\|f\|_{W^{1,2}}:=\|f\|_{L^2}+\|f'\|_{L^2}$. So if you prove the above inequality for all smooth $f$ with appropriate conditions, then by continuity of the integral you automatically have the result for all $f\in W^{1,2}$.