Anything that has mass will have gravity ( Exhibit a phenomemon called gravitation) not just black holes. One way of understanding gravity was put forth by Newton as his law of gravitation. As @christo said, there is no clear knowledge of why it has gravity. A more generic way to put it would be to say, anything that has mass curves the space around it. The force or gravity you would feel can be considered as the way you are being forced to follow the curved lines instead of your intended path. This is how Einstein\’s general theory of relativity explains gravitation. In quantum mechanics, It is speculated that gravity is caused by exchanging particles called gravitons, think of it like the way you would play catch with your friends. Multiple objects having some mass throwing small balls called gravitons at each other. There is no evidence for the existence of gravitons yet, but it explains a lot of things in the quantum realm.
Astronauts and space tourists may rhapsodize about feeling weightless during spaceflight, but don\’t be fooled by the somewhat misleading term zero-gravity. Every object in space still feels the gravitational pull from other objects, including space travelers who imagine themselves free of Earth\’s gravitational shackles.
Earth\’s gravity affects everything at or near the planet\’s surface. We feel the force of gravity on Earth through our mass, and that force also translates into a downward pull of 9. 8 meters per second squared (32 ft/s^2). That\’s why astronauts need powerful machines such as the space shuttle\’s main engines and twin boosters or the Russian Soyuz rockets to travel beyond Earth\’s immediate gravitational tug. How to stay Gravity represents the mutual attraction between two objects, and the strength of that pull depends on both mass and the distance between the objects. Greater mass leads to a greater gravitational pull, as anyone who has fought to lose a few pounds knows firsthand. By contrast, greater distance leads to rapidly diminishing gravitational pull. But w here the space station roams, some 220 miles (354 km) up, the force of gravity is still about 90 percent what it is here on the surface. Earth\’s gravity is still pulling down on astronauts in orbit. A spacecraft or space station can counter Earth\’s downward pull by creating enough horizontal speed so that it continually slides sideways as it simultaneously falls toward the planet, creating an orbit.
For instance, the space shuttle typically travels at a blistering 17,000 to 18,000 mph around the Earth to stay aloft. That continuous free fall around the planet gives astronauts the impression of being weightless. Huge objects with enormous mass can make their gravitational effects felt across much greater distances. The moon maintains a free-falling orbit around the Earth, and the Earth itself remains in orbit around the massive sun. Our sun contains over 99 percent of all mass in the solar system, which explains why its gravitational pull has managed to snag eight planets and a host of other objects. Jupiter, the largest planet in our solar system, has also flexed its gravitational muscle across vast distances of space by pulling in space rocks and other debris which might otherwise threaten Earth. That has allowed Earth observers to also witness several spectacular impacts on the gas giant, such one that recently the size of the Pacific Ocean. Even asteroids and other smaller space rocks exert weak gravitational pull.
And on the flipside, some scientists have proposed using the mere mass of spacecraft to act as that gently tug threatening space rocks out of Earth\’s path. Albert Einstein proposed another way to think about gravity in space. Consider if the 3-D universe was a flat, 2-D sheet. Each object in space acts like a ball that weighs down on the space-time fabric and creates a bulging pocket similar to a shallow depression in the ground. That curvature of space-time has an inward falling effect on the paths of other objects, and particularly on smaller passing objects. It\’s like having a sheet stretched between two people, and watching a marble roll down into the bulge created by a large ball sitting on the sheet. More massive objects such as black holes create bigger bulging pockets of space-time, while tiny objects such as a spacefaring human would barely represent a dent. So gravity may be everywhere in space, but that won\’t stop astronauts or others from describing the wonderful feeling of weightlessness. Sometimes the illusion of human experience speaks volumes more than strict scientific fact.