We used to participate in the holy battles led by Allah's Apostle and we had nothing (no wives) with us. So we said, "Shall we get ourselves castrated?"
He forbade us that and then allowed us to marry women with a temporary contract and recited to us: "O you who believe! Make not unlawful the good things which Allah has made lawful for you, but commit no transgression." (5:87)