Near Earth vs Newtonian gravitational potential

Your equation (2) is the change in potential energy when the object moves vertically by a distance $h$ i.e. when the object moves from $r$ to $r+h$. Let's use equation (1) to calculate this:

$$ \Delta U = GMm\left(\frac{1}{r}-\frac{1}{r+h}\right) $$

Subtracting the two fractions inside the bracket gives:

$$\begin{align} \Delta U &= GMm\left(\frac{r+h}{r(r+h)}\frac{r}{r(r+h)}\right) \\ &= GMm\frac{h}{r(r+h)} \end{align}$$

Since $h \ll r$ that means $r+h\approx r$ and our equation becomes:

$$\begin{align} \Delta U &\approx GMm\frac{h}{r^2} \\ &\approx \frac{GM}{r^2}mh \\ &\approx gmh \end{align}$$

Footnote:

I've just noticed that in your comment to Itachí's answer you ask if you can use a Taylor series. You can use a binomial expansion to make the aproximation more obvious. You rewrite:

$$ \Delta U = GMm\frac{h}{r(r+h)} $$

as:

$$ \Delta U = \frac{GM}{r^2}mh\left(1+\frac{h}{r}\right)^{-1} $$

then a binomial expansion gives:

$$ \Delta U = \frac{GM}{r^2}mh\left(1-\frac{h}{r} + O\left(\frac{h}{r}\right)^2 \right) $$

And as before since $h \ll r$ the term in the brackets is approximately one and we once again get:

$$ \Delta U = \frac{GM}{r^2}mh $$


Given a force $F$, the work done on an object over a distance between two points $s_0$ and $s_f$ by that force is $$W=-\int_{s_0}^{s_f} Fds$$ In the case of gravity, $$F=\frac{GMm}{r^2},\quad ds=dr$$ Thus, in the case where $U=W$, $s_0=0$ and $s_f=r$, so $$U=\frac{GMm}{r}$$ Now, over small distances by the Earth's surface, the force is approximately constant. If we substitute in $$g\equiv\frac{GM}{r_e^2}$$ and assume that $g$ is essentially constant between our reference point and $h$, we can say that $$\Delta U=\int_0^hmgds=mg\int_0^hds=mgh$$ So $(1)$ is the actual expression for the potential energy at a point if we assume that $g$ changes; $(2)$ is an approximation if we assume that the change in $g$ is small. This is valid near Earth's surface, as John Rennie showed, but it's generally not valid over large distances.

I should note something about reference points. In the case of $(1)$, $r$ is a coordinate from the center of mass $M$; in the case of $(2)$, $h$ is a coordinate from some arbitrary reference point from the center of $M$. Generally, you could take this to be the radius of the Earth, but it's often unimportant for conservation of energy problems, and you can choose any value that makes the calculations simpler - so long as $g$ is approximately constant.