Why should spouse get anything just because she was a spouse? What's the legal justification? It's basically debt slavery for men, despite owing nothing.
The idea behind it is to accomodate for career sacrifices. If a woman is a stay at home mom for 25 years for example, kids are now adults (so no child support) and the husband leave (or became toxic, so she file for divorce) how is she going to live or restart her career? She made that career sacrifice with the idea that his work is hers too. Even if there was no kids and she was the one taking care of the house, it is still sacrifice.
It all stems from the idea that there is no "his/her" money when married, it is both their work and their money, and if it is broken, both parties finalize divorce with the idea to compensate for the broken marriage.
I am not saying it is right or wrong btw, it isn't the system here for example, and in general it feels a bit outdated system and can be unfair. Although, there is no way to make a system that is fair all the time.