It is not just a case of gravity. It is a question of escape velocity. This, as Loosehead correctly points out, is all to do with density. As an object gets closer to the centre of gravity of a body, the velocity needed by the object to overcome the gravitational force of the body increases. The denser a body is, the closer its surface will be to its centre of gravity. Escape velocity for the earth is about 25,000 mph. This is about 0.00004c (c = the speed of light, which is about 670 million mph).
For bodies of �normal� densities the issue of escape velocity approaching c does not arise. However, when super-dense bodies such as collapsed stars are considered, things begin to change.
When a star dies the nuclear reactions which kept it in equilibrium cease. Gravity, now being unopposed, takes over. The star collapses, and its density is raised to unbelievable values. What happens to the star ultimately depends upon its mass. Those of less than 1.3 solar masses shrink to become white dwarfs, and eventually black dwarfs. These burnt out cinders of stars may exhibit densities of hundreds of tons per cubic inch, but because of their relatively small mass, they will not collapse further. Nonetheless, escape velocity from objects such as this could reach 0.3c. This is the likely fate of our Sun.
Stars of between 1.3 and 3.0 solar masses collapse further to form �Neutron Stars�. These may have escape velocities up to 0.5c. Only those above 3 solar masses have the potential to collapse even further. There seems to be no theoretical limit to their shrinkage and it is these objects that can potentially form �Black Holes, where the escape velocity is greater than c.
For the Sun to be a Black Hole it would have to have a diameter of no more than about 4 miles (it is currently 800,000 miles in diameter). For the Earth to be a Black Hole it would have to be about the size of a table-tennis ball.