I actually know everything in the answers so far, but I still have the same question. If we ignore expansion, because that likely only complicates the issue, and imagine a nearly homogeneous isothermal universe, with only the variations we see in the CMB, and just wait long enough, what happens? If there was no gravity, then entropy concerns suggest the variations would get even smaller with time, because that would increase entropy. But when gravity is turned on, it seems that now we have gravitational instabilities that must find a different path to increasing entropy by increasing density and temperature variations. The ability for gravitational potential energy to drop into a well and create photons, which in turn generate entropy, must somehow compensate for the loss of entropy associated with the density concentrations. But I've never seen this explained clearly, as to how we know that gravity releases enough energy to be able to cause entropy to increase. Were it not so, surely there would not be gravitational instability, and there would not be stars, but I've never seen it concisely explained as to how this is able to work.
Which raises an even more unclear question for me, which is, how does gravitational instability work for dark matter, which does not release gravitational energy in the form of light, but instead can only add kinetic energy to the gas itself? How can we see easily that the gravitational energy released when a dark matter structure shrinks allows it to have access to more states by virtue of its kinetic energy than it loses by virtue of its volume loss?
Indeed, the Sackur-Tetrode (
https://en.wikipedia.org/wiki/Sackur–Tetrode_equation) entropy of an ideal gas is a constant per particle plus the natural log of V U
3/2, where V is the volume occupied and U is the internal energy. So if gravity shrinks a system and dumps all the energy into kinetic energy, then V U
3/2 would decrease with V. That wouldn't obey the virial theorem, so we might expect only half the gravitational energy to show up in U, while the other half is transported somewhere else, but simply transporting kinetic energy somewhere else does not necessarily seem like a good way to increase entropy. It's also not obvious that turning it into light will guarantee that entropy increases. So I'm quite unclear on how gravitational instabilities, for either normal or dark matter, raise entropy, making this a very good question indeed.