[proofplan]
We show that the harmonic function $u$ uniquely minimises the Dirichlet energy by expanding $D[v] = D[u + w]$ where $w = v - u$ vanishes on $\partial\Omega$.
The cross term $\int \nabla u \cdot \nabla w$ vanishes by Green's first identity (using $\Delta u = 0$ and $w = 0$ on $\partial\Omega$), leaving $D[v] = D[u] + \frac{1}{2}\int |\nabla w|^2 \geq D[u]$.
The converse (minimiser is harmonic) follows from the first variation.
[/proofplan]
[step:Decompose the energy of a competitor $v = u + w$ with $w = 0$ on $\partial\Omega$]
Let $u$ solve $\Delta u = 0$ in $\Omega$ with $u = g$ on $\partial\Omega$.
Let $v$ be any admissible competitor with $v = g$ on $\partial\Omega$.
Define $w := v - u$, so $w = 0$ on $\partial\Omega$.
Expanding the energy:
\begin{align*}
D[v] &= \frac{1}{2}\int_\Omega |\nabla u + \nabla w|^2 \, d\mathcal{L}^n \\
&= \frac{1}{2}\int_\Omega |\nabla u|^2 \, d\mathcal{L}^n + \int_\Omega \nabla u \cdot \nabla w \, d\mathcal{L}^n + \frac{1}{2}\int_\Omega |\nabla w|^2 \, d\mathcal{L}^n \\
&= D[u] + \int_\Omega \nabla u \cdot \nabla w \, d\mathcal{L}^n + \frac{1}{2}\int_\Omega |\nabla w|^2 \, d\mathcal{L}^n.
\end{align*}
[/step]
[step:Show the cross term vanishes by Green's first identity]
Apply Green's first identity:
\begin{align*}
\int_\Omega \nabla u \cdot \nabla w \, d\mathcal{L}^n = -\int_\Omega w\,\Delta u \, d\mathcal{L}^n + \int_{\partial\Omega} w\frac{\partial u}{\partial\nu} \, d\mathcal{H}^{n-1}.
\end{align*}
The first term vanishes because $\Delta u = 0$ in $\Omega$.
The second vanishes because $w = 0$ on $\partial\Omega$.
[/step]
[step:Conclude uniqueness of the minimiser]
Substituting back:
\begin{align*}
D[v] = D[u] + \frac{1}{2}\int_\Omega |\nabla w|^2 \, d\mathcal{L}^n \geq D[u],
\end{align*}
with equality if and only if $\nabla w \equiv 0$ in $\Omega$.
Since $w$ vanishes on $\partial\Omega$ and $\Omega$ is connected, $\nabla w \equiv 0$ implies $w \equiv 0$, so $v = u$.
[/step]
[step:Show the converse: any minimiser of $D[\cdot]$ is harmonic]
If $u$ minimises $D[\cdot]$ among admissible functions, then for any $\phi \in C_c^\infty(\Omega)$ and $\varepsilon \in \mathbb{R}$:
\begin{align*}
D[u + \varepsilon\phi] = D[u] + \varepsilon\int_\Omega \nabla u \cdot \nabla\phi \, d\mathcal{L}^n + \frac{\varepsilon^2}{2}\int_\Omega |\nabla\phi|^2 \, d\mathcal{L}^n.
\end{align*}
The minimality condition $\frac{d}{d\varepsilon}\big|_{\varepsilon=0} D[u + \varepsilon\phi] = 0$ gives $\int_\Omega \nabla u \cdot \nabla\phi \, d\mathcal{L}^n = 0$ for all $\phi \in C_c^\infty(\Omega)$.
Since $u \in C^2(\Omega)$, integration by parts (the boundary term vanishes because $\phi$ has compact support in $\Omega$) yields $-\int_\Omega \phi\,\Delta u \, d\mathcal{L}^n = 0$ for all $\phi \in C_c^\infty(\Omega)$.
By the fundamental lemma of the calculus of variations, $\Delta u = 0$ pointwise in $\Omega$.
[/step]