The formal steps are as follows: introduce an infinitesimal variation $u(x)\mapsto u(x)+\epsilon(x)$, and compute the variation of the functional to first order in $\epsilon$. Denote by $V$ the region within which $u\geq 0$, and $S$ the surface on which $u=0$, which is the boundary of $V$. The variation is $$L[u+\epsilon]=\int_V|\nabla (u+\epsilon)|^2\,dx + \int_V\chi_{\{u+\epsilon > 0\}}\,dx$$ $$=L[u]+\int_V 2(\nabla u)\cdot(\nabla\epsilon) \,dx + \int_{S} \frac{\epsilon}{n\cdot\nabla u}\,dx+{\cal O}(\epsilon^2)$$ $$=L[u]-\int_V \epsilon|\nabla u|^2 \,dx +\int_{S} \epsilon\left(2n\cdot\nabla u + \frac{1}{n\cdot\nabla u}\right)\,dx+{\cal O}(\epsilon^2)$$ The variation of $L$ vanishes for arbitrary $\epsilon$ if the integrand of the volume integral $\int_V$ and the integrand of the surface integral $\int_{S}$ each vanish identically, so $$|\nabla u|^2=0\;\;\text{in}\;\;V,$$ $$2(n\cdot\nabla u)^2+1=0\;\;\text{on}\;\;S.$$