Adding to the other answer from @user2544542. Jesus had to present himself to the Father on the day of the resurrection, pure and unblemished, as an offering of first fruits. Therefore Mary Magdalene could not touch him until this was accomplished.
When Jesus appears to Mary next to the tomb, he forbids her from touching (or holding) him. But we read further that:
On the evening of that first day of the week, when the disciples were together, with the doors locked for fear of the Jewish leaders, Jesus came and stood among them and said, “Peace be with you!” After he said this, he showed them his hands and side. The disciples were overjoyed when they saw the Lord.
John does not explicitly say that the disciples were welcome to touch him, but Luke's gospel does. Luke 24:13 confirms that two disciples met Jesus on the road to Emmaus "that same day" (the day of the resurrection), then went back to Jerusalem after Jesus revealed himself to them and disappeared before their eyes to tell the Eleven what had happened.
While they were still talking about this, Jesus himself stood among them and said to them, “Peace be with you.” They were startled and frightened, thinking they saw a ghost. He said to them, “Why are you troubled, and why do doubts rise in your minds? Look at my hands and my feet. It is I myself! Touch me and see; a ghost does not have flesh and bones, as you see I have.” When he had said this, he showed them his hands and feet. And while they still did not believe it because of joy and amazement, he asked them, “Do you have anything here to eat?” They gave him a piece of broiled fish, and he took it and ate it in their presence.
It had taken the two disciples until almost dark to reach Emmaus. They sat down to eat and Jesus broke bread and disappeared. They hurried back to Jerusalem at once, but would have arrived back very late at night. So in effect it was certainly the next day (the day starting at sunset) when Jesus appeared to the Eleven in the room with them.
But by that time, the disciples were instructed to touch his hands and feet. This seems to be something like 18-24 hours after he forbade Mary from holding him, which was around dawn.
So what changed?
The day of the resurrection was also the appointed day of first fruits. There is some amazing prophetic timing at play here. Leviticus 23:4-16:
The LORD said to Moses, “Speak to the Israelites and say to them: ‘When you enter the land I am going to give you and you reap its harvest, bring to the priest a sheaf of the first grain you harvest. He is to wave the sheaf before the Lord so it will be accepted on your behalf; the priest is to wave it on the day after the Sabbath. ... This is to be a lasting ordinance for the generations to come, wherever you live. From the day after the Sabbath, the day you brought the sheaf of the wave offering, count off seven full weeks. Count off fifty days up to the day after the seventh Sabbath, and then present an offering of new grain to the Lord.
This is the passage that establishes Shavuot / Pentecost. What is interesting here is that the day after the seventh Sabbath is said to be the 50th day after the first fruits offering. But when do the people "enter the land"? Joshua 4:19:
On the tenth day of the first month the people went up from the Jordan and camped at Gilgal on the eastern border of Jericho.
The Israelites literally entered the Land of Israel four days before Passover. That was the same day the Passover lamb was to be selected. Exodus 12:3-6
... On the tenth day of this month each man is to take a lamb for his family, one for each household. ... Take care of them until the fourteenth day of the month, when all the members of the community of Israel must slaughter them at twilight.
OK, so the 10th day of the first month is "when you enter the land". And the day after the next "Sabbath" after that is the start of seven weeks, followed by Shavuot / Pentecost. There is just one problem. There is no guarantee that the days of the week will line up with the days of the first month to make this true.
The resolution is that the day after Passover is a Sabbath. Leviticus 23:5-8:
The LORD’s Passover begins at twilight on the fourteenth day of the first month. On the fifteenth day of that month the Lord’s Festival of Unleavened Bread begins; for seven days you must eat bread made without yeast. On the first day hold a sacred assembly and do no regular work. For seven days present a food offering to the Lord. And on the seventh day hold a sacred assembly and do no regular work.
These passages imply that the 49th day, the day just before Shavuot, is also a Sabbath, even if it does not fall on the weekly Sabbath.
Jewish practices today generally differ somewhat from what is written. Passover is said to be celebrated nowadays starting on the 15th day of Nisan, though the candles are lit before sunset, while it is still the 14th. But the death and resurrection of Jesus seems to follow what is written quite literally.
Getting to the point, we can see that the day of the resurrection coincided with the appointed offering of the first fruits. John 19:31 says:
Now it was the day of Preparation, and the next day was to be a special Sabbath. Because the Jewish leaders did not want the bodies left on the crosses during the Sabbath, they asked Pilate to have the legs broken and the bodies taken down.
I will hold the rest of the timeline to be common knowledge, but it is documented in the gospels.
- Jesus holds the Passover meal, beginning it just after sunset so that their seder is held on the 14th day of the first month.
- During the meal Judas Iscariot leaves to bring the Romans to arrest Jesus. Jesus takes the disciples to the Mount of Olives and prays.
- Jesus is arrested the night of the 14th and taken before Pilate and Herod.
- The day of the 14th Pilate acquits him but the crowd chooses to free Barabbas instead and crucify Jesus.
- Jesus is crucified and dies on the 14th late in the day and is buried before sunset in a newly dug tomb. He dies on Passover itself. Day 1 of his burial.
- The day after Passover is the feast of Unleavened Bread and a "special Sabbath". (Although from the phrasing in Luke, it seems also to have been the weekly Sabbath by coincidence.) Jesus remains entombed the entire day. Day 2 of his burial.
- Early in the morning the stone is miraculously rolled away from his now-empty tomb. He rises from the dead on the third day, which is the day of first fruits in scripture.
- He forbids Mary Magdalene to touch him and sometime that day presents himself to the Father.
- The next night, Jesus appears to his disciples and instructs them to touch him, to prove he is not a ghost.
While Jesus never fully explains this within the pages of scripture, we may infer that he had to appear before the Father in his role as a priest, to present the first fruits (likely his own resurrection) to the Father as a kind of offering. By the next night, this had been accomplished and it was no longer important for his disciples to avoid touching him.
A footnote. In Matthew 28:8-9 we read:
So the women hurried away from the tomb, afraid yet filled with joy, and ran to tell his disciples. Suddenly Jesus met them. “Greetings,” he said. They came to him, clasped his feet and worshiped him.
By comparing the narratives in the four gospels, this must have been just after Mary Magdalene attempted to hold him when she saw him at the tomb. This seems to imply that touching his feet would not be a problem in the same way that Mary holding him would. Or perhaps even in that brief amount of time, which could have been mere moments, Jesus had presented himself to the Father, and now it wasn't important any more that he not be touched.