It tries to populate each possible graylevel 0 to 255 equally in the image. The input image has very weak dark values that are near black. But black and white are the predominant values. So HE causes many of the dark but not black values to be more populated and so show up where they used to be similar to black. Thus they turn gray. It is sort of like spreading the dark values out to the same number of counts, so decreasing the pure black count while increasing the near black counts so that the the counts are more even in the histogram. This causes a very noisy image, when you start with basically two predominant colors (white and black). See https://en.wikipedia.org/wiki/Histogram_equalization

When a region of an image contains a narrow range of values, and the image as a whole doesn't contain an adjacent range of values, many of the values in the region will be shifted to fill in the missing portion of the histogram. This will increase the contrast within that region. Increasing contrast exagerates small differences between pixels. When small differences are irrelevant noise, this noise becomes visible.

In this example, a large region is mostly black, and the image as a whole is missing mid-gray values. So many near-black pixels become mid-gray. This massively increases the contrast in that region.

Techniques are available to limit the increase im contrast. See my "[Adaptive] Contrast-limited equalisation" page.