Let's see if we can analyze the situation and see exactly what transpired in this situation.
John 20:16 through 18 ESV Jesus said to her, "Mary." She turned and said to him in Aramaic, "Rabboni!" (which means Teacher). Jesus said to her, "Do not cling to me, for I have not yet ascended to the Father; but go to my brothers and say to them, 'I am ascending to my Father and your Father, to my God and your God.'" Mary Magdalene went and announced to the disciples, "I have seen the Lord"—and that he had said these things to her.
These are the verses just prior to the ones you quoted, and we see here that first of all Jesus had not yet ascended to the father. So apparently there was some reason of which we are unaware that Jesus had to return to the Father and the Holy Spirit, before anything else could happen in the physical realm.
One theory is that he had to go to heaven in his physical body and deposit it somewhere, and reassume his Spiritual being. But that of course is conjecture.
Now let's take a look at verse 19.
John 20:19 ESV On the evening of that day, the first day of the week, the doors being locked where the disciples were for fear of the Jews, Jesus came and stood among them and said to them, "Peace be with you."
Notice that it says on the evening of that same day The importance of this comes from:
John 14:25 through 27 ESV "These things I have spoken to you while I am still with you. But the Helper, the Holy Spirit, whom the Father will send in my name, he will teach you all things and bring to your remembrance all that I have said to you. Peace I leave with you; my peace I give to you. Not as the world gives do I give to you. Let not your hearts be troubled, neither let them be afraid.
When Jesus ascended to the father he returned with the Holy Spirit, but knew he could not stay himself since he had to return to where the Father was in order to take his rightful place at the right hand of then power as is indicated in:
Matthew 26:64 Jesus said to him, "You have said so. But I tell you, from now on you will see the Son of Man seated at the right hand of Power and coming on the clouds of heaven."
Mark 14:62 And Jesus said, "I am, and you will see the Son of Man seated at the right hand of Power, and coming with the clouds of heaven."
Luke 22:69 But from now on the Son of Man shall be seated at the right hand of the power of God."
Now when Jesus breathed on them He was giving them a special form of the Holy Spirit, and a special power to begin the spread of the Gospel.
John 20:21 through 23 ESV Jesus said to them again, "Peace be with you. As the Father has sent me, even so I am sending you." And when he had said this, he breathed on them and said to them, "Receive the Holy Spirit. If you forgive the sins of any, they are forgiven them; if you withhold forgiveness from any, it is withheld."
notice that he said as the Father sent me so I am sending you, Jesus was giving them special powers just as the Father had given him the ability to forgive sins on Earth.
Matthew 9:2 And behold, some people brought to him a paralytic, lying on a bed. And when Jesus saw their faith, he said to the paralytic, "Take heart, my son; your sins are forgiven."
and
Matthew 9:5 For which is easier, to say, 'Your sins are forgiven,' or to say, 'Rise and walk'?
It is important to notice that Jesus said *' Your sins are forgiven' and not your sins will be forgiven.
This is important because:
Matthew 9:6 But that you may know that the Son of Man has authority on earth to forgive sins"—he then said to the paralytic—"Rise, pick up your bed and go home."
Remember this was before the Holy Spirit came down to inhabit all Christians.
Act 2:1 through 4 When the day of Pentecost arrived, they were all together in one place. And suddenly there came from heaven a sound like a mighty rushing wind, and it filled the entire house where they were sitting. And divided tongues as of fire appeared to them and rested on each one of them. And they were all filled with the Holy Spirit and began to speak in other tongues as the Spirit gave them utterance.
Hope this helps.