Extending regular function on normal variety from a subvariety of codimension 2 In his book "Commutative Algebra with a View Toward Algebraic Geometry" Eisenbud proves the Corollary 11.4 which states the following 
If $R$ is a normal Noetherian domain, then $R$ is the intersection of its localizations at codimension-1 primes.
Then he writes that the geometric version of this fact is the following:
If $X$ is a normal variety and $Y\subset X$ is a subvariety of codimension at least 2, then any rational rational function on $X$ regular on $X\setminus Y$ extends to a regular function everywhere on $X$.
My question is, why is it true?

This is how to translate the algebraic statement into geometry (the geometric intuition was already given in a comment): Let $X={\rm Spec}(A)$ with a normal domain $A$. Let $Y=V(I)$ with ${\rm ht}(I) \geq 2$ and $U=X \setminus Y$. We have $U = \bigcup_{f \in I} D(f)$, where $D(f)$ denote the basis open sets of Zariski topology.
Let $\frac{a}{b} \in {\rm Frac}(A)$ be a rational function on $X$, which is regular on $U$. We have to show that it is regular on $X$.
Let $\mathfrak p$ be a prime of height $1$. From ${\rm ht}(I) \geq 2$ we deduce that there exists $f \in I$ with $f \notin \mathfrak p$, which means $A_f \subset A_{\mathfrak p}$. $\frac{a}{b}$ is regular on $U$, so in particular regular on $D(f) \subset U$. We deduce $\frac{a}{b} \in \mathcal O(D(f)) = A_f \subset A_{\mathfrak p}$. Since $\mathfrak p$ was arbitrary of height $1$, we have shown
$$\frac{a}{b} \in \bigcap_{{\rm ht}(\mathfrak p)=1} A_{\mathfrak p}.$$
And now you see the connection with Corollary 11.4 of Eisenbud, which tells us $\bigcap_{{\rm ht}(\mathfrak p)=1} A_{\mathfrak p}=A$, hence $\frac{a}{b}$ is regular on $X$.
Furthermore we know that for any variety the restriction map $\mathcal O_X(X) \to \mathcal O_X(U)$ is injective, hence an extension of a regular function on $U$ is unique if it exists. This uniqueness makes sure we can reduce the general case to the affine case by a standard glueing argument.
