Gravitational instability
The key idea in explaining the way in which structures evolve in the universe is gravitational instability. If material is to be brought together to form structures, then a long-range force is required, and gravity is the only known possibility. (Although electromagnetism is a long-range force, charge neutrality demands that its influence is unimportant on large scales.) The basic picture is as follows. Suppose that at some initial time, say decoupling, there are small irregularities in the distribution of matter. Those regions with more matter will exert a greater gravitational force on their neighboring regions, and  hence tend to draw in the surrounding material. This extra material makes them even more dense than before, increasing their gravitational attraction and further enhancing their pull on their neighbors. An irregular distribution of matter is therefore unstable under the influence of gravity, becoming more and more irregular as time goes by. This instability is exactly what is needed to explain the observation that the Universe is much more irregular now than at decoupling, and gravitational instability is almost universally accepted to be the primary influence leading to the formation of structures in the Universe. It is an appealingly simple  picture, rather spoiled in real life by the fact that while gravity may have the lead role, numerous other processes also have a part to play and things become quite complicated. For example, we know that radiation has pressure proportional to its density, and during structure formation the irregularities create pressure gradients which lead to forces opposing the gravitational collapse. We know that neutrinos move relativistically and do not interact with other material, and so they are able to escape from structures as they form. And once structure formation begins, the complex astrophysics of stars, especially supernovae, can inject energy  back into the intergalactic regions and influence regions yet to complete their gravitational collapse.