How does gravity affect the universe?
With the appearance of dark energy/matter, no one knows.
It was only about 50 years ago that astronomers thought the expansion of the universe was slowing down because of its inherent matter. That is, since every bit of matter has its own gravity and considering how much gravity must exist to hold the universe together as it is, it was thought that the expansion would stop and contraction began.
But in the intervening years three things happened. First, scientists discovered that not only is the expansion of the universe not slowing down, it is still accelerating. And they could not, and still cannot, explain that phenomena.
Then astronomers did an atom count of sorts. That is, they figured out how much mass they could see throughout the universe and from that calculate its associated gravity. But when the counting was done, they discovered there exists far too much gravity in the universe to be explained by the universe we can see. In fact, the matter we can see amounts to about only 5% of the total mass needed to account for the total gravity in the universe.
At this point enters dark matter. It is postulated that dark matter play a role in this but as of now astronomers and physicists are at a loss to explain that role in as much as dark matter has never been detected nor its properties defined.
Like so many things in science, when one question is answered another 10 take its place.