At the time when Jesus' trial was to commence before the High priest, John readily went inside the courtyard because he knew the high priest well, whereas Peter was relatively unknown in the place. Yet Peter was stopped at the gate and John was not.

John 18:15-17 Simon Peter and another disciple followed them as they brought Jesus to Annas. (Now the other disciple was acquainted with the high priest, and he went with Jesus into the high priest’s courtyard.) But Simon Peter was left standing outside by the door. So the other disciple who was acquainted with the high priest came out and spoke to the slave girl who watched the door, and brought Peter inside. The girl who was the doorkeeper said to Peter, “You’re not one of this man’s disciples too, are you?” He replied, “I am not.”

The fact that the slave girl allowed John inside and not Peter is a bit puzzling. If John was well known to the High priest, then how is that they did not know that he was Jesus' disciple? What could be the rational reason, that they allowed John inside and not Peter?

2 Answers
2

Bible tells that as soon as Jesus was arrested, all His disciples fled and went into hiding. So there was this possibility that whoever known to be close to Jesus would be arrested or tried like Jesus.

Matt. 26:56 But this has happened so that the scriptures of the prophets would be fulfilled.” Then all the disciples left him and fled.

So there could be two possibilities. First: Peter was reluctant to enter inside lest he might be recognised by the people to be disciple of Jesus and land in trouble just like Jesus. Second: Peter was stopped because he was an unknown person trying to enter into a sensitive area.

In case of the “other disciple”: Like the Beloved Disciple, this other disciple is unnamed, closely associated with Peter and characterized as having special knowledge, wanted Peter to come inside to witness the trial of Jesus. Note that John says that this other disciple “knew the high priest and went into the courtyard with Jesus” indicating that in the courtyard this other disciple was not known to be a close disciple of Jesus or else he would have been in the same danger as other disciples.

Gill's commentary says:

If this Apostle is thought to be John, because he frequently speaks of himself in Gospel of John, then he is supposed to be known to the high priest, by carrying fish to his house, and selling it to him; so Nonnus says, he was known from his fishing trade and it is not probable that he was known, or could be known by the high priest, so as to have any intimacy with him; nor is it likely that he, being a Galilaean, would venture in; he was discoverable by his speech, and would have been in equal danger with Peter.

Or possibility is that this desciple was some other disciples of Christ, who had not openly professed him; one of the chief rulers that believed in him, but, for fear of the Pharisees, had not confessed him; or it may be Nicodemus, or Joseph of Arimathea, or the man at whose house Christ had eaten the passover. In the Syriac version he is called one of the other disciples; not of the twelve, but others.

Adam Clarke in his commentary on the bible states that:

For this “another disciple”, there are many conjectures who this disciple was: Jerome, Chrysostom, Theophylact, Nonnus, Lyra, Erasmus, Piscator, and others, say it was John.

Clarke however further says that:

“It is true John frequently mentions himself in the third person; but then he has always, whom Jesus loved, as in Joh 13:23; Joh 19:26; Joh 21:7, Joh 21:20, except in John 19:35, where he has plainly pointed out himself as writer of this Gospel. So in this instance verse, he has mentioned no circumstance by which that disciple may be known to be John.

Conclusion: So Peter was stopped either because he was an unknown person entering the sensitive area or Peter was reluctant to go inside courtyard out of fear that he might be recognised, yet his love for his master brought him till the gate.

Whereas the other disciple, if he is John the apostle, was either not known in the courtyard to be close disciple of Jesus as Gill,s commentary suggest or he was brave enough to face any danger unlike Peter or this other disciple was not from the twelve apostles.

When reading the Bible, you need to find other scriptures linking to the same context/text

First of all, the High Priest isn't John but Caiaphas: In Matthew 26, this states:

56 But all this was done, that the scriptures of the prophets might be
fulfilled. Then all the disciples forsook him, and fled.

All the disciple left. The only one that followed Jesus was Peter and another disciple, known to the high priest. This disciple was not amongst the 12 as the Bible would have mentioned a name.

The slavegirl only allowed the high priest in the house and those acquainted with the high priest. The other disciple had to come back and fetch Peter. This shows that he convinced the high priests upon entering that it was ok to bring Peter in their interrogation meeting.

Welcome to the site! This next has nothing to do with the quality of your answer, it's just standard to help new visitors avoid misunderstanding the site (as I did at first.) As a new visitor, I'd recommend checking out the following two posts, which are meant to help newcomers "learn the ropes": the help page and How we are different than other sites?
–
David Stratton♦Dec 4 '13 at 1:52