The potential energy is due to the gravitational attraction between the two- earth and the body. The gravitational force is acting on the body and as the body is brought from infinity to some distance r, a mutual energy of the 2 bodies is expended. In simple terms, when the earth is attracting the body towards itself, the body moves in the attracted direction.
This gravitational attraction is generated to the huge rotational mass of the two bodies. The Earth rotates and revolves and the rotational energy of the Earth creates a force of attraction between it and the body.
The concept is similar to those observed in everyday life. Remember your mother asking you to stand away from the train when it's in motion? Simple reason: the train is moving at a great speed and has a good amount of mass, the attraction energy can attraction your body to the moving train and hence, prove lethal to you.