According to the Torah (Shemot 13:13), if the owner of a firstborn donkey does not wish to redeem it by exchanging it for a lamb, then the donkey must be decapitated.
The Gemara quotes a baraita that explains this law as follows:
If he did not wish to redeem the donkey, he breaks its neck from behind with a kufitz – a cleaver – from the back and buries it, and it is prohibited to derive benefit from it. These are the teachings of Rabbi Yehuda. And Rabbi Shimon permits one to derive benefit from it.
‘He must not kill the donkey with a reed, nor with a sickle, nor with an ax, nor with a saw. Nor may one put it in a room and close the door, in order that it may die. And it is forbidden to shear it or to use it for labor. These are the teachings of Rabbi Yehuda. And Rabbi Shimon permits this!’
Ultimately, the Gemara concludes that the disagreement between Rabbi Yehuda and Rabbi Shimon in both parts of the baraita refers to a living animal, but the first part refers to monetary benefit, and the second part refers to the benefit derived from its body (its wool or its work). In both of these situations, Rabbi Shimon permits use of the firstborn prior to its decapitation and Rabbi Yehuda forbids deriving such benefit.
In his Mishneh Torah, the Rambam (Hilkhot Bikkurim 12:2) rules like Rabbi Yehuda and says that if the firstborn is sold, the money derived from the sale is forbidden. The Ra’avad questions this ruling, arguing that there are only two situations where a forbidden object transfers its status to money for which it is exchanged – avoda zara and shevi’it.
Rabbi Akiva Eger suggests that this case may be unique. Ordinarily it is impossible to transfer the prohibition from a given object by means of redemption, so the money received in exchange does not become prohibited. In the case of a firstborn donkey, we know that redeeming it does remove the prohibition from it, so it is possible to transfer that prohibition to money that is exchanged for it.
Rashi offers a different scenario for the case of monetary benefit – payment made when the animal is rented. Since he does not suggest the case where the animal is sold it appears that the money is not intrinsically forbidden, rather it is a penalty imposed on the owner – since he wanted to cause a loss to the kohen, we cause him to lose out.