You've undoubtably seen the rubber sheet analogy for spacetime curvature, and I'd guess you're thinking that things fall into the dimples on the sheet. This is certainly true and is an analogy for how gravity works between astronomical bodies like stars.
However the rubber sheet as a whole can expand and contract, and this is an analogy for how spacetime as a whole expands and contracts. For a closed universe you have to imagine the rubber sheet expanding at early times as the universe expands, reaching a maximum stretch, then shrinking again at later times as the universe contracts.
The usual caveats apply: be cautious about taking the rubber sheet analogy too literally. Googling will find you many articles describing the deficiencies of the rubber sheet analogy e.g. this one. Also note that in the contraction phase we are not talking about a finite sheet contracting to a point. The sheet is infinite at all times - the contraction to a singularity means the spacing between any two randomly chosen points on the sheet goes to zero at the Big Crunch.
The answer by @peterh is accurate on the factual information about the Einstein Field Equations and that it describes how the matter distribution affects spacetime. There is more that may be added that hopefully will help understand more of it.
First, just to be totally clear, gravity as described by GR (general relativity, through Einsteins Field Equations) is due to the curvature of spacetime, which is caused by any kind of matter energy. Thus, you can say matter-energy causes gravity, which is the curvature of spacetime. As the spacetime curves matter then follows the curves in spacetime that are the shortest path between 2 points, called the geodesics. Yes, one creates gravity and spacetime, which affects everything in it. It is a set of very nonlinear equations. Thus, in this geometrical description of gravity, there is no force. We still call it the effect the gravity, or the gravitational field effect
Still, it turns out that the geometric description, when the gravitational field is not too strong, can be described as a force and Newton's equations and description of gravity are a very good approximation in those cases. The gravitational force of the earth can for the most part be described that way, and all orbits computed accurately enough that way. The same is true for the sun. There are some minor effects that Newtons equations cannot describe in those cases:
1) there is a small time dilation effect, where time is just a tiny bit slower on the surface of the earth than it is where the GPS satellites keep track of time, and those are then slightly adjusted. 2) the orbits of the planets have their perihelion shift just slightly, and it's been observed.
GR describes those perfectly.
Your question of why the critical density affects whether the uNiverse keep expandinged forever (an open universe), collapses back (closed universe, Big Crunch), or just barely keeps going (flat) is actually a little more complex. Remember the Einstein Field Equations. They can be written as
Einstein Tensor = k X [Energy-momentum tensor + dark energy term]
(The dark energy term was originally on the left side, as a cosmological constant term. Different words for the same thing)
When one solves this set of equations (there are 10 independent equations, the different components of the Tensors), for homogeneous isotropic spacetimes (a very limited set, called Robertson Walker solutions, really 3, with positive, negative or zero SPATIAL curvature), you get the Friedman equations. Those relate the density of matter energy to the curvature. The critical density is simply that density which makes the SPATIAL curvature zero, or flat, a so called flat universe (words again, it really is only the spatial part that has no curvature, there is an expansion which makes the spacetime curved).
So if the density is equal to the critical density, spacetime is so called flat. It has been measured and estimated to be so within about 2%. And yes about 70% of that density is the dark energy, and about 25% dark matter. Both dark matter and dark energy are mysterious, but there is evidence of their existence.
For dark matter it is well determined that they are around and inside galaxies, and help keep them as such. Galaxies rotate too fast to not have their stars fly away due to the centrifugal effect, and that has been used to determine the density of dark matter around and in galaxies. It is thought they are massive particles that are remnants of the Big Bang because they interact very weakly (no strong nuclear nor electromagnetic interactions, only the weak nuclear and gravity) with themselves and other matter. The specific particles have not yet been directly detected, so there can always be some surprises.
Dark energy is even more mysterious. Try some of the answers on this site about it or Wikipedia for a quick summary. We don't know what it is, but there is also evidence that it exists. Galaxies further away from us are expanding faster, accelerating, and the numerical observations are consistent with a constant dark energy density at about 70% of critical. When and if we find out what it really is there can also be surprises. See also https://en.m.wikipedia.org/wiki/Dark_energy
In both cases, the most accurate measurements are due to the cosmological microwave background. See https://en.m.wikipedia.org/wiki/Cosmic_microwave_background.
It predicts the cosmological parameters very accurately, but still some uncertainties
So, yes, energy and matter density affects spacetime, and for the universe its expansion. If the total energy density is critical it is a flat universe.
Best Answer
There are two issues to talk about: gravitation acting within the universe (star formation, solar systems, galaxies and things like that) and the cosmology of the whole universe.
The first is easier. When a cloud collapses by its own gravitation, the net entropy increases. Here is a quote from p.377 of "Thermodynamics, a complete undergraduate course" (Steane, OUP 2018)
"For low enough initial temperature, the self-gravitating cloud cannot be stable because when any given part of the whole cloud loses energy, that part gets hotter and shrinks, while another part gains energy, gets colder and expands. The temperature difference is now enhanced so the process continues. The net result is that the fluctuations in density or temperature in the cloud grow, and the whole process is called condensation. The parts that shrink lose entropy, while the parts that expand gain entropy, and there is a net entropy increase because, as usual, the direction of heat flow at any time is such as to guarantee this. There is no violation of the Second Law. On the contrary: the Second Law is fully obeyed, as it is in all of physics."
If you are puzzled by the statement "gains energy, gets colder" then you need to recall that there is potential energy involved as well.
Now let's turn to the larger cosmological issue which you asked about. Over the past fifty years from time to time there has arisen, in the theoretical physics community, claims along the lines that time would reverse if the universe were to re-contract, and so entropy would decrease. Such claims are based on attempts to think through what general relativity has to say about particle motion. However it is safe to say that those claims were never really established and most of the physics community has found them unconvincing. Certainly quantum field theory would not change if the cosmological scale factor got smaller rather than larger. All of physics would just carry on as before. So there is no good reason to think that entropy would decrease.
The conclusion of the above is that a big crunch would have high entropy not low entropy.
The early universe, by contrast, had low entropy. We can say this because all the processes we have figured out are entropy-increasing processes. Therefore the entropy at early times must have been smaller than it is now. And this is, furthermore, a strong statement: the entropy was very much smaller. To try to get an idea of what it means to say this, one can try to imagine the state-space of the cosmos. Then the statement is that the physical situation occupied, at early times, a tiny volume within this state-space. However I admit that I personally am not altogether sure of how one can be confident of ones reasoning here. The main message is that it is not true to say that the early state was merely amorphous; such statements ignore the great amount of structure residing in the configuration of the quantum fields at very early times, and later in the hot plasma. The very fact that the plasma was highly uniform (without being completely uniform) is the very thing that shows that its entropy was low. This seems surprising if you think of it as like an ideal gas, but owing to the self-gravitation that picture is very misleading.