You've constructed a very interesting problem. What is happening here is, essentially, that the calculations of p-values assume a certain amount of randomness in the observed correlation between, in this case, $y$ and $x_2$, under the null hypothesis, but the way you have constructed $x_2$ - as the residual from a regression of $z$ on $x$, which forces the correlation between $x_2$ and $z$ to be exactly equal to $0$ all the time - has reduced that randomness below what the null hypothesis would typically indicate. The end result is that the observed correlations between $y$ and $x_2$ are more tightly clustered around $0$ than would be expected, so the associated p-values are more tightly stacked up near $1$ than the uniform distribution that would be expected.
Mathematically, we can write $y = w + z$, where $w = $0.2*rnorm(n=100)
in your code. Then, using the independence of $w$ and $z$, the null hypothesis is "expecting":
$$\rho(y,x) = f(\rho(w,x),\rho(z,x))$$
The exact equation of $f$ isn't important, although it's easy enough to write out. Due to the fact that $x$, as you have constructed it, has zero correlation with $z$, what the calculations are actually seeing is:
$$\rho(y,x) = f(\rho(w,x),0)$$
This will cause the correlation between $x$ and $y$ in the second case to almost always be smaller than the correlation between $x$ and $y$ in the first case. We can see this in the histograms below:


Note the difference in the scale on the x-axes.
x1
is the difference of two std normal distributions, so a std.n.d. again,x2
is the residuals of a linear model with an intercept, are you sure these two variables are similar? $\endgroup$ – user2974951 Sep 13 '18 at 8:02x1
has a sample average close to $0$ whilex2
has a sample average exactly $0$. The sample correlation between them typically seems to be over $0.99$ $\endgroup$ – Henry Sep 13 '18 at 8:12plot(x1,x2)
$\endgroup$ – Henry Sep 13 '18 at 8:16plot.ecdf(p1)
as close to uniform butplot.ecdf(p2)
skewed towards $1$, the opposite of your question $\endgroup$ – Henry Sep 13 '18 at 8:26