It is a denial of the agency of the individual to prohibit them from agreeing to something else.
If so, your definition of freedom is terrible.
That concern is weighed against other considerations, including whether or not to allow society to coerce individuals into degrading situations.
Law -- like any other human construction -- is about trade-offs.