To be more specific, i was wondering about the legal aspect of the issue. Does a person own his/her body? If not, who owns it? If yes, then can a person sell themselves into slavery? Prostitution? What legal justifications can be given for such law? (e.g., Harm Principle, utilitarianism, legal moralism, paternalism).
Self-ownership is sometimes considered the fundamental commitment of political libertarianism. For example, consider the opening sentences of the SEPH article on "Libertarianism":
In the most general sense, libertarianism is a political philosophy that affirms the rights of individuals to liberty, to acquire, keep, and exchange their holdings, and considers the protection of individual rights the primary role for the state. This entry is on libertarianism in the narrower sense of the moral view that agents initially fully own themselves and have certain moral powers to acquire property rights in external things. [emphasis added]
It's controversial whether self-ownership implies that you have the right to sell yourself into slavery. Usually this possibility is treated as an objection to libertarianism. (Search in the SEPh article for "voluntary enslavement.") I seem to recall that Nozick had some cryptic remarks in Anarchy, State, and Utopia that suggest but don't state outright that you do have the right to sell yourself into slavery.
Libertarians generally agree that prostitution is morally permissible and should be legal.
Two non-libertarian discussions of self-ownership are worth mentioning. In the introduction to Self-ownership, Freedom, and Equality, G.A. Cohen observes that self-ownership seems to be a central commitment of both libertarianism and the kind of Marxism he was raised with in working-class Montréal. Over the course of the book, he critically engages with Robert Nozick's version of libertarianism, and ultimately rejects self-ownership.
In Justice, Gender, and the Family, Susan Moller Okin presents a deep feminist critique of libertarianism. Okin's argument has been neglected in the literature; I wrote a comprehensive review of replies to Okin, with responses to those replies a few years ago. (I discussed every reply to Okin that I could find, except for one very technical reply that had to be cut due to word limits.) Specifically, I argued that Okin's argument creates a fundamental dilemma for libertarianism: either people do not own themselves or justice requires at least some involuntary transfers of property.
Does a person own his/her body?
If a person owns his or her body, then it follows that he or she can sell it. But this necessitates the institution of slavery; once I have sold myself into slavery, my owner has the right to have his property protected by the State, so that if I change my mind and flee away, the State has an obligation to return me to my owner.
Fortunately, most, if not all, States have abolished such nefarious institution, and forbidden people from selling themselves. So it seems that most, or all, States do not believe that a person owns her body.
If not, who owns it?
No one? Who owns the Moon, the Sun, the bottom of the ocean, the intellectual property rights to the wheel or pottery?
If yes, then can a person sell themselves into slavery?
Well, anyone can do whatever they wish, including arson, murder, and jaywalking. So the question is, can they legally do this? And the answer is no. If John sells himself to Joseph, this is a fictitious contract. Any time John wants to be free again, Joseph cannot enforce his supposed "property rights" upon him. The State will not enforce such rights for him, and if he tries to do it by himself, he is almost certainly committing a crime. This is true in New York or Berlin, Moscow or Jacarta, Ryiad or Stockholm, and is only less true in those parts of the world where no State authority is able to assert itself.
Contrary to the libertarian fiction, rights only exist where the State upholds them.
People cannot sell themselves, as seen above, but they can certainly sell their time. Otherwise wage labour would be as impossible as slavery. As such is not yet the case, there must be a fundamental distinction between ownership over one's body, and ownership over one's labour time.
Of course, there is no contradiction between being a slave and being a prostitute. But there is no contradiction between being an agricultural labourer and being a slave. Heck, there is no contradiction between being a philosopher and being a slave; Epictetus was both. But slavery is a formal relation, not a material one. Epictetus was a slave because he was captured, enslaved, and sold, not because he was a philosopher. The same is true of a prostitute; she is a slave if she belongs to another person; otherwise she is something else.
What legal justifications can be given for such law?
For what law? Slavery, or its abolition?
Slavery was legally justified by war; since vanquishers had a life and dead right over their victims, and since in eo quod plus est semper inest et minus, if they could kill them, they could instead spare them as... property.
The abolition of slavery is justified by the contradictions involved in slavery - if a slave is property, then s/he is not a person; if s/he is not a person, then their own illegal actions cannot be framed in criminal law; if their illegal actions are framed under criminal law, then they are persons; if they are persons, then they are not property.
This is an excellent question. While I find the previous answer linking the question to libertarianism interesting, is it not a little unrelated to the question as asked, which is about the law?
There is a burgeoning philosophical and legal theory of body ownership, wrought in part by the burgeoning science of gene manipulation. Donna Dickenson has an excellent exposition in a Philosophy Bites interview, 15 minutes long. She addresses the legal question.
The basis of the law, in Common Law countries, is not philosophy, but tradition.
Traditionally, one's family owned one's body. In various codes of Weregelt, if you were severely injured, it was not to you that the money or rights were paid so that the infraction could be 'for-given'. It was to the clan of your extended family.
This moral stance was related to the metaphor behind fealty. The family had cultivated you, like a crop or a herd animal, and it had earned the right to its product. You owed them for your childhood, and for keeping you alive in the present. And in exactly the same way, the clan had cultivated your extended family line. Exogamous marriage itself was a trade between families or clans, sometimes moving money or rights from the clan of the spouse who left home to live among their partner's people, or requiring a ritual theft or contest that transferred responsibility for that spouse's maintenance to the new family.
Feudalism gave way to the notion of the nation-state, and clans were concentrated up into monarchies, which eventually distributed their power into democracies of some form. But the traditional basis here remained. You belong to the entity that protects you militarily.
The institution that guarantees your rights also determines what they are. And to that degree, you remain the property of the state. It is their responsibility to educate you and to enable a functional economic system that allows you to leverage your work, by creating some degree of peace and order. To the degree they succeed, you owe them. A part of your labor is beholden to them according to the tax code, and they retain the right to make laws that can determine whether you may commit suicide, or sell yourself into slavery or prostitution.
In a democracy, this is joint ownership of all of us by one another, but it remains real enough ownership that most Western democracies have at some point recently had military conscription, even in peacetime. If you can be ordered to report bodily to an institution that will then determine most of your future actions until they decide they are done with you, you clearly do not own your own body.