Why do people ever sign contracts? Every contract is a restriction on your future courses of action. That's the point - a contract that doesn't bind you to do something in the future isn't a contract.
The reason why we've evolved contracts at all is because it changes how people behave. When people know that bad things will happen when they break a contract, they are much less likely to break the contract. That in turn lets other people trust that the events stipulated in the contract will in fact occur, even if it is against the other party's immediate self-interest, and so they can act on the assumption that that future will be true. So for example: people sign confidentiality agreements with their employers because without them, the employer isn't going to share any information that's important to the business, and without that information, you can't do your job, and if you can't do your job, your value is zero to your employer and they're not going to pay you. Knowing that they can sue you for a lot of money if you spread trade secrets around, though, they can feel reasonably secure in telling you those trade secrets. It's against your immediate self-interest to be bound by any restrictions on your freedom of speech, but it's definitely in your long-term self-interest to have a job and develop professional skills which you wouldn't otherwise have.
So it is with marriage. The reason people get married is because it changes how our spouse behaves toward us, because they know our incentives are much more in favor of remaining within the relationship, and so they're willing to invest more and sacrifice more for your benefit, because there's a reasonable assumption that it will come back around to benefit them. Sure, people can behave that way anyways - but it's often not rational to, and many people get screwed by behaving as if they are married when their spouse actually has no intention of ever marrying them.
The reason why we've evolved contracts at all is because it changes how people behave. When people know that bad things will happen when they break a contract, they are much less likely to break the contract. That in turn lets other people trust that the events stipulated in the contract will in fact occur, even if it is against the other party's immediate self-interest, and so they can act on the assumption that that future will be true. So for example: people sign confidentiality agreements with their employers because without them, the employer isn't going to share any information that's important to the business, and without that information, you can't do your job, and if you can't do your job, your value is zero to your employer and they're not going to pay you. Knowing that they can sue you for a lot of money if you spread trade secrets around, though, they can feel reasonably secure in telling you those trade secrets. It's against your immediate self-interest to be bound by any restrictions on your freedom of speech, but it's definitely in your long-term self-interest to have a job and develop professional skills which you wouldn't otherwise have.
So it is with marriage. The reason people get married is because it changes how our spouse behaves toward us, because they know our incentives are much more in favor of remaining within the relationship, and so they're willing to invest more and sacrifice more for your benefit, because there's a reasonable assumption that it will come back around to benefit them. Sure, people can behave that way anyways - but it's often not rational to, and many people get screwed by behaving as if they are married when their spouse actually has no intention of ever marrying them.