On the right hand of the expression above, why could we move the condition ' |X ' to the numerator without making any other changes?
2 Answers
If the value of $X$ is known, $X_i-\bar{X}$ and $(X_i-\bar{X})^2$ are known quantities, and so the only random variables that are unknown are the $U_i$. More simply, remember that $E[Y\mid X]$ is a function of $X$, not of $Y$ as one might think, and $E[f(X)Y\mid X]$ equals $f(X)E[Y\mid X]$, which is also a function of $X$ and not of $Y$.
The notation $\mathbb E[\cdot|X]$ is just a notation for the conditional expectation that associates to a random variable $Z$ the random variable $\mathbb E[Z|X]$ as the closest function of $X$, in the sense of the least square solution $$f^* = \arg \min_f \mathbb E[(Z-f(X))^2]$$ i.e. $f^*(X)=\mathbb E[Z|X]$. The notation $|X$ thus does not have a meaning by itself and cannot be "moved" around the expectation argument. In other words, $Y|X$ does not exist.