This belief is based on the Gospel of Barnabas, promoted by the Vulgate Bible, and generally recognized as a false belief by most Muslims.
The Vulgate is a generally accurate translation into Latin of the Bible, and makes no mention of such a story.
There was a quite tasteless story circulating among the 2nd century Gnostics: according to them, Simon of Cyrene was crucified in Jesus' place, while the latter stood nearby laughing at how easily the Romans had been fooled. I think that is ultimately the source of the verse in the Koran, surah 4:157, that states:
"They declared: 'We have put to death the Messiah, Jesus son of Mary, the apostle of God.' They did not kill him, nor did they crucify him, but they thought they did."