As I know gravitational potential energy of an object relative to $U=0$ point is defined as $U(h)=mgh$ and this came from work-energy theorem.
But In my book, there is another definition for it.
Consider that we have 2 objects that can interract with each other by gravitational force. Set the first object steady. Now, there is $\vec{r_{0}}$ distance between these two objects. Move the second object $d\vec{r}$ in direction $\vec{r_{0}}$/$\hat{r_{0}}$. Let's call $\vec{r}$ to new distance.
Work done by us (agent),
$$\vec{F}_{g}=-G\frac{M_{1}M_{2}}{r^2}\hat{r}$$
$$\vec{F}_{ag}=-\vec{F}_{g}=G\frac{M_{1}M_{2}}{r^2}\hat{r}$$
$$W(\text{done by us})=W_{ag}=\int_{r_{0}}^{r}\vec{F}_{ag}.d\vec{r}$$
$$W_{ag}=\int_{r_{0}}^{r}{G\frac{M_{1}M_{2}}{r^2}\hat{r}.dr\hat{r}}$$
$$W_{ag}=GM_{1}M_{2}\int_{r_{0}}^{r}{\frac{1}{r^2}dr}$$
$$W_{ag}=GM_{1}M_{2}(-\frac{1}{r}+\frac{1}{r_{0}})$$
$$W_{ag}=-G\frac{M_{1}M_{2}}{r}+G\frac{M_{1}M_{2}}{r_{0}}$$
$$r_{0}\to\infty\Rightarrow G\frac{M_{1}M_{2}}{r_{0}}=0$$
$$U(r)=-G\frac{M_{1}M_{2}}{r}$$
This is it. What is the difference?