Why should the ex wife/husband be entitled to that money by law?

Usually the reason given is that they are accustomed to a certain standard of living. But didn't they forgo that standard when they filed for divorce? Or if they were not the one to file, why did they put all their eggs in one basket and assume they would be with that one person forever?

It is a one sided benefit. The partner who chose to earn less and willingly went into the marriage is rewarded for no longer being married. The other partner gets nothing, except a new bill to pay every month.