Gravitational potential energy of a two body system from infinity In determining gravitational energy of a two body system,we define it as the negative work done by gravitational force in bringing those two bodies from infinity to a distance $r$ with respect to the first body.
Now in doing this, we say that work done by gravity in bringing the first body to a certain distance is $0$ because there is no gravitational field in our destination. And then we calculate the work done in bringing the second body due to the gravitational field created by first body.
But I didn't get why work done by first body is $0$. Because as the first body starts moving from infinity,gravitational force still backwards between that body and the second body though the first body is moving forward. In that case,how can work done be $0$?
 A: Gravitational potential energy in a two body system is a function of the separation of the two bodies, not their absolute locations. So if you want to use a work-energy argument to determine the potential energy at a separation $r$ then your initial condition is that the two bodies are separated by an infinite distance, when $PE=0$, and then brought closer together. Since gravity is a conservative force it does not matter which body is moved (or, indeed, if both are moved at the same time) or what paths they take. The only relevant points are their initial separation and their final separation.
Your other error is to think of infinity as if it were a single location rather than a separation (or, strictly speaking, the limiting case of larger and larger separations). “At infinity” means “having an infinite separation from each other”, not “at a location that we call infinity”.
A: The misconception here is that the second body is present (i.e., not at infinity) while the first body is being moved into position. The work done on the first body when it is moved from infinity assumes there are no other sources of gravitational potential. You can think of it as if both bodies start out at infinity. When the first body is moved to a finite distance, the distance between the first body (now not at infinity) and the second body (still at infinity) is infinity, and since potential energy goes as $U\sim-\frac{1}{r}$, naturally $\lim_{r\to\infty} -\frac{1}{r} = 0$.
We see something similar in electromagnetism, with the electrostatic energy.
