This view is based primarily on Matthew 16:18–19, in which Jesus says:
And I tell you, you are Peter, and on this rock I will build my church, and the gates of hell shall not prevail against it. 19 I will give you the keys of the kingdom of heaven, and whatever you bind on earth shall be bound in heaven, and whatever you loose on earth shall be loosed in heaven. (ESV)
When this concept of "keys" belonging to Peter is combined with the teaching from Revelation 21:12, that the New Jerusalem has walls and gates, it's not a huge leap to see Peter as being the gatekeeper of heaven, who allows entrance to some but not others.
However, this is as explicit as the Bible itself gets on this question. There are a few other sources for Petrine authority, like Matthew 18:18, but the popular image of Peter standing at the pearly gates is a later interpretation or extrapolation of the scriptures. Leading church historian Everett Ferguson identifies a possible source:2
The passage [Matthew 16:18–19] moves from a building, to gates, to keys. A popular image has Peter as the doorkeeper of heaven, deciding admission through the pearly gates to each person at death. This understanding of Peter goes back to an early medieval interpretation that identified Peter with a figure in Germanic mythology who was the porter of heaven. (The Church of Christ, 53)
Numerous others make the same connection between the passage and the popular imagery, like Miriam Van Scott in Encyclopedia of Heaven, 208 and Howard Clarke, who ties this imagery to medieval drama (The Gospel of Matthew and Its Readers, 146).