How gravity can give energy for unlimited time? F = gravitational force between the earth and the moon, 
G = Universal gravitational constant = 6.67 x 10^(-11) Nm^2/(kg)^2, 
m = mass of the moon = 7.36 × 10^(22) kg 
M = mass of the earth = 5.9742 × 10^(24) and 
r = distance between the earth and the moon = 384,402 km 

F = 6.67 x 10^(-11) * (7.36 × 10^(22) * 5.9742 × 10^(24) / (384,402 )^2 
F = 1.985 x 10^(26) N

The above all i took from  http://in.answers.yahoo.com/question/index?qid=20071109190734AATk6NV
Age of Moon 4.53 billion years (From google)
So Earth has been producing a force of 1.985 x 10^(26) N for 4.53 billion years
I do not know how to calculate the total energy spent so far(Please some one do the favor) from force and time but it must be very huge.
if E = mc^2 then atleast some of the mass of earth must have disappeared in producing this energy or where did the energy come from ? 
Somewhere some one has answered if we place a ball above earth then during that time we did the work and when it fell down to the earth that work changed into kinetic energy ok accepted but the moon is being pulled towards earth for unlimited time where does the earth get the energy from to do so ?
@Emilio Pisanty
Thanks for your reply.
"it needs to move the object in the direction that the force acts in"
Even though the force applied by earth is perpendicular to the direction of motion the moon's direction is definitely changed because of the force applied by the earth and the moon is moving a little towards earth from the straight line otherwise the motion would be a straight line.
If earth did no work on moon why would the moon not go in straight line escaping earth's gravity.
Even if we accept that earth does no work and spends no energy in making the moon orbit around it,By newton's law any body which accelerates needs force and since the moon keeps accelerating all the time(changing its direction of movement)where does moon gets this force continuously for such a long time.
 A: Exerting a force and providing energy are quite different things. In particular, to provide energy to a body the force needs to perform work, that is, it needs to move the object in the direction that the force acts in. In the case of the Moon, the movement is circular and perpendicular to the gravitational force, so there is no inwards / outwards motion.* The gravitational force of the Earth on the Moon performs no work and therefore does not provide energy.
As a matter of fact, the Moon is actually drifting away from the Earth, at the rate of 38mm per year. This requires energy, as the Moon is being pushed against the Earth's gravitational force; this energy is taken from the Earth's rotation (which slows down by about 15μs per year) and it is transferred via tidal mechanisms.
If you do your numbers correctly (using the SI unit m instead of km for the distance) you'll find the gravitational attraction between the Earth and the Moon is $F\approx 1.8\times10^{20}\:\mathrm N$, so over a year the tidal interaction performs the work $W=Fd=6.8\times10^{18}\:\mathrm J$. If that seems astronomical, then yeah, that's what astronomical numbers tend to look like - calculate the rotational energy of the Earth and you'll see just how big this number is.
* To a first approximation. The Moon's orbit is actually elliptical, so there is a slight inwards movement, in which the moon speeds up and gains energy, but it loses it two weeks later during the equivalent outwards movement. 

Regarding your edit:

If earth did no work on moon why would the moon not go in straight line escaping earth's gravity. 

In a circular orbit, the force changes the direction of the movement but it does not change the speed, so it does not change the kinetic energy. There's a difference between performing work (exerting a force which causes an acceleration in the direction of movement, thus changing the object's kinetic energy), and exerting a force orthogonal to the direction of movement. It is possible to exert a force that causes acceleration (by changing the direction of movement) without performing work. 

Even if we accept that earth does no work and spends no energy in making the moon orbit around it,

You don't need to conditionally accept it. It's true.

By newton's law any body which accelerates needs force and since the moon keeps accelerating all the time(changing its direction of movement)where does moon gets this force continuously for such a long time.

There is no principle of "conservation of force". Bodies can exert as much force as they want to on each other, for unlimited amounts of time. This is perfectly OK by the laws of physics. (There is, of course, the principle of conservation of energy, which says that bodies cannot perform unlimited amounts of work on each other, but as I've explained it does not apply to the Moon because the Earth does not perform work on it to keep it in orbit.) I don't know how else to phrase this - but what makes you think that this is a problem?
A: The gravitational potential energy is the energy stored in the gravitationnal field not in the masses them selves, the energy $E = mc^2$ is the mass-energy equivalence (at rest), think of it as energy has mass, most of the matter mass is due to the quark-gluon plasma energy and contributions from higgs mechanism,the more energetic particle the more massive, and potential energy have nothing to do with the energy mass equivalence, (if so it leads to a paradox, both masses have potential energy, they get more massive and P.E keep on increasing as mass does to infinity)
