In my functional analysis course, we are studying the extension operator and there is something I really don't understand. Let me explain my problem for the case $\Omega = \mathbb R^n_+ = \{x \in \mathbb R^n~|~x_n > 0\}$ and $k = 1$.
For such an open set, there is a linear continuous operator $P: W^{1, p}(\mathbb R^n_+) \to W^{1, p}(\mathbb R^n)$ such that $(Pu)|_{\mathbb R^n_+} = u$. To construct such an operator, we use the approximation of $W^{1, p}(\mathbb R^n_+)$ by $C^\infty (\overline{\mathbb R^n_+})\cap W^{1, p}(\mathbb R^n_+)$ to define $$ Pu(x',x_n) = \begin{cases} u(x', x_n) & \text{if }~ x_n \ge 0,\\ u(x', -x_n) & \text{if }~ x_n < 0, \end{cases} $$ Such that $Pu \in W^{1, p}(\mathbb R^n)$ and we can conclude by density. It is the same kind of argument on $\Omega$ smooth and bounded.
My question is the following: why do we need to construct the extension like that ? It seems much more natural to define $$ Pu(x',x_n) = \begin{cases} u(x', x_n) & \text{if }~ x_n \ge 0,\\ 0 & \text{if }~ x_n < 0. \end{cases} $$ What could possibly goes wrong with the extension by zero of functions of $W^{1, p}(\Omega)$ ?
Your problem is the jump of the derivative of the function at the boundary!
Indeed, for a function in $L^2(\Omega)$, it is natural to extend by $0$ outside. However, for a function $u \in H^1(\Omega)$, if you extend by $0$ outside $\Omega$, you might have that $u$ is discontinuous at $\partial \Omega$, and therefore nothing ensures you that
$$\nabla u \in L^2(\mathbb{R}^n).$$
However, if $u \in H^1_0(\Omega)$, you can extend by $0$ without any problem.