The verse states: "And Midianite men passed by, merchants; and they drew and lifted Yosef out of the pit, and sold Yosef to the Ishmaelites for twenty pieces of silver; and they brought Yosef to Egypt" (Bereshit 37:28). The Midrash clarifies that when the Midianites pulled Yosef out, the brothers claimed that Yosef was their slave; nevertheless, they were willing to sell him for twenty selaim (pieces of silver).
One can explain the reason why they sold him for twenty pieces of silver based on what our Sages said in the Talmud (Megillah 16b): "Because of the weight of two selaim of fine wool that Yaakov added to Yosef over his brothers, it came about that our ancestors descended to Egypt."
That is, the ketonet passim — the tunic of fine wool — that Yaakov made for Yosef had the value of two selaim. And because of that garment which Yaakov gave to Yosef over and above his brothers, they felt jealousy, and the entire descent to Egypt was triggered.
Therefore, they sold him for twenty pieces of silver: in this way, two selaim corresponded to each of them (assuming ten brothers were involved), with which they could buy for themselves a tunic similar to Yosef's. Measure for measure.
Zera Shimshon, Parashat Miketz, Art. 17