HG31 has the sprockets painted black. I'm not sure, but the largest ones may also be on a riveted steel spider construction, eliminating the possibility of recycling any of the unworn sprockets.
HG41 is nickel plated and looks much shiner, and may be more resistant to corrosion. The sprockets are usually individual ones pinned together and can be seperated (once the pin heads are ground off) to make custom ratios or reuse unworn sprockets. Hardly anyone does this but I often keep unworn/low wear 32, 34 and 36t sprockets to make cassettes with lower gear ranges than normal, which can be useful for some people.
Lifespan and performance will be similar though the shiny nickel is easier to clean than the matt black