There is a 'critical density' of materials which governs whether they will keep going apart or coalesce.
On the largest scale, it is used in order to determine whether the Universe will collapse, in the end (closed), keep on expanding more and more (open) or keep expanding but slower and slower (flat).
As material moves away from a centre of a distributed mass (say a group of galaxies or a cloud of dust OR the Universe itself), it has a certain amount of Kinetic Energy (KE), by virtue of its movement. It also has a certain amount of (negative) gravitational potential energy (GPE) by virtue of its being attracted to the centre of gravity of the mass. If there is more KE than GPE, then the mass will carry on expanding because there will be KE to spare . If it is less, then the mass will collapse because there is not enough KE.
The average density of the region of interest determines how much GPE it has which, in turn, tells you whether it will expand or collapse eventually.