Check $cov(X,e)=0$ using residuals I know it is wrong but I am not sure why. We run a linear regression
$$ Y = a + bX + e$$
we get the residual
$$ \hat{e} = Y  -(\hat{a}+ \hat{b} X)$$
Why can we not check $cov(X,e)=0$ using  $corr(X,\hat{e})$? Is it because $\hat{e}$ is also biased?

The OLS machinery forces that correlation to be zero.
Consequently, your test cannot detect the endogeneity you hope to catch.
In the simulation below, I show the error term and the included feature to be highly correlated. However, the correlation between the OLS residuals and the included feature are zero (up to some numerical funkiness that comes from doing math on a computer). The other regression is there to show that this need. It happen for other estimation approaches, however, minimizing absolute loss in this case.
library(quantreg)
set.seed(2022)
N <- 30
x1 <- runif(N, 0, 5)
x2 <- x1 + rnorm(N)
e <- rnorm(N)
y <- x1 + x2 + e
cor(x1, x2) # 0.869
cor(x1, x2 + e) # 0.690
L <- lm(y ~ x1) # OLS
Q <- rq(y ~ x1) # Minimize absolute loss
cor(resid(L), x1) # Basically zero
cor(resid(Q), x1) # 0.114

