This is a general question but discussed in Gittin. It is forbidden to free a Canaanite slave. There is a procedure to free a Canaanite slave. Why is there a procedure for something that is forbidden?
Barry Epstein, Dallas, USA
Allow me to separate your question into two questions, the premise and the specific. As for the premise: the Torah gives procedures for other forbidden things, such as Temurah. The rationale is that although it works in Metzi'us, in reality, don't do it.
However, this specific case is not an appropriate example. The Ran writes that it is only forbidden to free a slave needlessly. However, for a necessity, such as for a Mitzvah it is allowed. This is illustrated in the case of Rebbi Elazar, discussed in Berachos 47b, who freed his slave for a Minyan. Also, according to many opinions in the Gemara, someone who blinds or maims his Eved must write a Shtar to free him (the slave does not automatically go free). We therefore need the procedure for the cases when one must free his slave.
D. Zupnik