Theorem: Let $A \subset C(K)$ such that
$A$ is a subalgebra with unity $1$
For each $x, y \in K $ with $x \neq y $, there exists $f \in A$ such that $f(x)\neq f(y)$.
Then $ \overline A = C(K)$, where $C(K)$ is the space of continuous functions over the compact space $K$.
Proof: We have to show that for every function $f\in C(K)$, for every $x\in K$ and for every $\epsilon>0$, there exists $g_x \in \overline A$ such that $g_x\le f+\epsilon$ and $g(x)>f(x)$.
Then we define $\ h_{xy}$ by $h_{xy}$=p$g_{xy}$(z)+q, where constants p and q are such that $\ h_{xy}$(x)=f(x)+$\epsilon$/2 and $\ h_{xy}$(y)=f(y)-$\epsilon$/2.
Then by 1), $h_{xy}$ $\in$ A.
My question is: why can we say $h_{xy}$ $\in$ A by 1) ?
Following the PDF in this question, we get $g_{xy} \in \mathcal{A}$ such that $\alpha:=g_{xy}(x) \neq \beta :=g_{xy}(y)$, as the algebra separates points (as this property is called). Then $1 \in \mathcal{A}$, and $\mathcal{A}$ being an algebra (so closed under scalar multiplication with the field $\mathbb{R}$), gives us that all constant functions are in $\mathcal{A}$ as well, and as $\mathcal{A}$ is closed under addition and pointwise multiplication, it contains all functions of the form $pg_{xy} + q$. Now the simple observation is that there is a linear function (from reals to reals) that maps the two distinct points $\alpha$ and $\beta$ to the points $f(x) - \frac{\varepsilon}{2}$ and $f(x) + {\varepsilon \over 2}$. This linear function $z \mapsto pz + q$ (easily computable) gives us the constant functions $p$ and $q$ and the $h_{xy} \in \mathcal{A}$ as required.
Added
The next step in the proof is to use the $h_{xy}$ that were just constructed to show
$$\forall f \in C^0(X,\mathbb{R}) : \forall x \in X: \forall \varepsilon >0 : \exists g_x \in \overline{\mathcal{A}}: g_x(x) > f(x) \text{ and } g_x \le f+\varepsilon\text{,}$$ where $g_x \le f+\varepsilon$ means that for all $p \in X$ we have $g_x(p) \le f(p) + \varepsilon$, so it lies uniformly below. To do this he defines an open cover based on the $h_{xy}$ (for the fixed $x$ we are trying to show this for) and varying $y \neq x$. The compactness then allows to make it into a "finite problem" where we can take the minimum of finitely many $h_{xy}$ to do the job of $g_x$, getting rid of the infinitely many $y \neq x$ that we were dealing with.
The very first part of the proof has shown the very useful fact:
$$h_1, h_2 \in \mathcal{A} \rightarrow \min(h_1, h_2),\max(h_1,h_2) \in \overline{\mathcal{A}}$$ which means that the $g_x$ all lie in $\overline{\mathcal{A}}$ as required.
The final step is to use the $g_x$ and get rid of the $x$, essentially$$\forall f \forall \varepsilon \exists g \in \overline{\mathcal{A}}: f \le g \le f+\varepsilon\text{,}$$ again using compactness, open covers and a $\max$ or $\min$, and as we use members of $\overline{\mathcal{A}}$ these lie in $\overline{\overline{\mathcal{A}}} = \overline{\mathcal{A}}$; in fact the first part of the proof can we seen as a lemma that the closure of an algebra is also an algebra, which is moreover closed under taking of $\min, \max$ and absolute values (so it has a lattice structure, besides the linear and multiplicative structure); I've sometimes seen the proof built up in that way, explicitly.
That last property is exactly what you want: $g$ lies in a small band defined by $\varepsilon$, because every inequality is now uniform over $x$. This is a common theme in compactness proofs: you can "do something" for every point in $X$ separately , and the compactness allows one to do this for all $x$ simultaneously, using some "finiteness argument". The last inequality implies that
$$||f -g||_{\infty} = \sup \{|f(x) - g(x)|: x \in X\} \le \varepsilon\text{,}$$ or equivalently that $g \in B(f,2\varepsilon)$ where the open ball is taken wrt this metric is defined by the norm $||\cdot||_{\infty}$. So every ball around $f$ with any centre $r>0$ intersects $\overline{\mathcal{A}}$, as witnessed by $g$ (say, take $\varepsilon < \frac{r}{2}$), so $f \in \overline{\overline{\mathcal{A}}} = \overline{\mathcal{A}}$, and as $f$ is arbitrary $\overline{\mathcal{A}} = C^0(X,Y)$ which was the goal.
Note that in a metric space $(M,d)$ (that $C^0(X,Y)$ with the uniform norm metric is) a set $D\subseteq M$ is dense if its closure equals the whole space, which means that for every $x \in M$, $x$ should be in $\overline{D}$ which means that every open ball $B(x,r)$ around $x$ should intersect $D$. The above is just this fact applied to the particular case at hand.
Hopefully the structure / logic of the proof is more clear this way. The goal is to reach the final stage, where starting with some $f$ and $\varepsilon>0$ we need some $g$ from the algebra (or its closure) uniformly close to $f$. We cannot do it right away, so first we must find the $g_x$ that are close to $f$ at $x$ and that stay uniformly below $f+\varepsilon$, and from these we make the required $g$. But to make the $g_x$ we need the $h_{xy}$ to fix things "locally" (for $x$ and $y$) and use the compactness again.. It's often a good idea to read longer proofs backwards. Assume we have the $g$ are we done? (yes), assuming we have the $g_x$ can we make a $g$ (yes), assuming we have $h_{xy}$ can we make $g_x$ (yes again) and to make these we need the assumptions on the algebra (it separates points and has constant functions) and we stay in the closure because that's what taking a min and max "costs" you. (You cannot prove that all algebras are closed under taking $\min$, but closed ones are).