Evenly distributed gas particles have higher entropy than particles clumped in one spot, yet evenly distributed mass has lower entropy compared to mass clumped in one spot. The confusion here is probably over the situations with and without gravity. First consider the situation when gravity is absent or negligible, such as a gas in a room on the Earth. In this case, the more clumped state could expand, potentially doing work in the process. This phenomenon happens every day within the cylinders of an internal-combustion engine.
Gases expand rapidly and push the piston, doing work.
Now consider the case when gravity is important. A self-gravitating aggregation of gas possesses some gravitational potential energy. As it collapses to a more clumped state, it releases gravitational potential energy. This gravitational potential energy could, in principle, do work. The more clumped the gas, the less gravitational potential energy it possesses, and the smaller is its capacity to do work.