According to Zeidler, 1995, in his book "Applied Functional Analysis: Application to Mathematical Physics".
Dirichlet problem is a problem to minimize $$F(u)=\frac{1}{2}\int_G(u')^2\ dx-\int_G fu\ dx,\qquad u=g \textrm{ in } bd(G).$$ Then, He says
If $G$ is open, bounded, nonempty subset of $\mathbb{R}$ and given continuous functions $f:G\rightarrow\mathbb{R}$ and $g:bd(G)\rightarrow\mathbb{R}$. Then, for $u\in C^2(\overline{G})$:
$1.$ If $u$ is solution to Dirichlet problem then $u$ is also a solution to generalized boundary value problem $$\int_G u'v'\ dx=\int_G fv\ dx,\qquad\forall v\in C_0^\infty(G)$$ $2.$ $u$ is a solution to boundary value problem $$-u''=f,\qquad \textrm{in } G$$ $$u=g,\qquad \textrm{in }\partial G$$ if and only if $u$ is a solution to generalized boundary value problem $$\int_G u'v'\ dx=\int_G fv\ dx,\qquad\forall v\in C_0^\infty(G)$$
After that, he gives explanation that there is a Dirichlet problem which doesn't have solution (so Dirichlet Principle can't be justified). What I know about this, later on, is that the solution space needs to be complete so the Dirichlet Principle can be justified.
Therefore, the Dirichlet problem needs to be generalized by introducing Sobolev Space $W_2^1(G)$. The generalized Dirichlet Problem is to minimize the function $$\frac{1}{2}\int_G (\partial u)^2\ dx-\int_G fu\ dx, \qquad u-g\in \overset{\circ}{W^1_2}(G),$$ where $\partial u$ denotes weak derivatives of $u.$
The Dirichlet Principle is stated as below:
If $G$ is open, bounded, nonempty subset of $\mathbb{R}$. Given two functions $f\in L_2(G)$ and $g\in W_2^1(G)$. Then, these are true:
$1.$ The Generalized Dirichlet Problem has a unique solution $u\in W_2^1(G).$
$2.$ Solution to Generalized Dirichlet Problem is also a solution to generalized boundary value problem $$\int_G \partial u \partial v \ dx=\int_G fv \ dx,\qquad \forall v\in \overset{\circ}{W^1_2}(G), \textrm{ and }u-g\in \overset{\circ}{W^1_2}(G)$$
My questions are:
Why the solution space $C^2(G)$ is generalized to $W_2^1(G)$? $C^2(G)$ is SECOND order continuously differentiable functions space while $W_2^1(G)$ is FIRST order weak derivable functions space.
Why the given function $g$ is generalized from only in $C(bd(G))$ to $W_2^1(G)$? The domain is extended from $bd(G)$ to $G$.
When proving the Dirichlet Principle, Zeidler, uses a theorem called Theorem in Quadratic Variational Problem, which only solved the minimizing problem and not the boundary condition, Why?
Note: Please help me. This is my undergraduate thesis topic and my undergraduate thesis defense seminar will be conducted on next Tuesday. Nobody familiar with this topic in my campus. So please, I'm desperately need an answer. Anything. Any explanation.
I'll try to hint on answers to your first and second question.
Ad 1. As my comment suggested, the $C^2$ regularity of $u$ is needed to give sense to the term $-u''=f$. If you consider the generalized boundary value problem only first order derivatives appear. Essentially, this is the reason why only $W^{1,2}$ functions are considered in the second problem.
Ad 2. In the generalized setting one requires a definition of boundary values of $W^{1,2}$ functions. An easy way is to consider boundary data that are in some sense inherited by $W^{1,2}$-functions. Here the so-called trace theorem comes into play.