bibleref puts in nicely:
The New Jerusalem is secure. Nothing and no one except what is
righteous is allowed to enter (Revelation 21:27). A massive high wall
with twelve gates surrounds the city. Twelve angels guard the gates.
The gates serve not only to symbolize security, but they also serve as
memorials. The names of the twelve tribes of Israel are inscribed on
the gates.
Walls and gates were used in Bible times to fortify cities. Wooden or
iron gates closed at night to keep out enemy soldiers and/or
plunderers. Inside the cities were narrow streets and courtyards.
Buildings stood around the courtyards. Of course, enemies were known
to scale the walls and crash the gates. When Jerusalem fell to the
Babylonians, the city's walls were left in ruins. It became Nehemiah's
mission to return from captivity to lead a delegation in the
rebuilding of Jerusalem's walls (Nehemiah 1). The wall of the New
Jerusalem will never fall, and its gates will never be breached.
This, of course, is meant as a highly symbolic gesture. In eternity,
there won't be any wickedness or unrighteousness to be protected from.
Nor will there be any evil, danger, or harm from which to be
protected. The existence of these walls, and gates, serve as
real-but-symbolic emblems proclaiming the safety and security of those
living in New Jerusalem.
The symbolism: We know that the twelve tribes of Israel are the Old Covenant community, while the twelve apostles are the New Covenant community established by Jesus Christ. By inscribing the names of the tribes on the gates and the names of the apostles on the foundations, it signifies the connection between the Old and New Covenants, with Jesus Christ serving as the cornerstone (Ephesians 2:20) that brings them together as the one who fulfilled the law (Matthew 5:17).
Foundations of ancient cities often are extensions of the rows of
stones making up the walls, going down to the bedrock. Jerusalem’s
first-century walls and foundation stones have been excavated. Huge
stones, some of which are five feet wide, four feet high and 30 feet
long, weighing more than 80 tons, go down 14 to 19 layers below ground
level.
Of more importance, however, are the names of the 12 apostles. This
illustrates what Paul writes about when he says the church is “built
on the foundation of the apostles and prophets, with Christ Jesus
Himself as the cornerstone. The whole building, being put together by
Him, grows into a holy sanctuary in the Lord. You also are being built
together for God’s dwelling in the Spirit” (Eph. 2:20-22).
[1]
On the Foundations: The stability and support of a structure are ensured by its foundations. By engraving the names of the twelve apostles on the foundations of the New Jerusalem, it highlights the fundamental importance of the apostles in founding and growing the Church. Selected by Jesus to bear witness to His teachings, crucifixion, and resurrection, the apostles were instrumental in sharing the Gospel worldwide. Therefore, the apostles symbolize the solid base on which the Church stands, with Jesus Christ serving as the cornerstone.
On the Gates: The inscriptions of the twelve tribes on the gates may represent God's commitment to His covenant promises to the patriarchs and the nation of Israel. In the Old Testament, God made various pledges to the tribes of Israel concerning their land, blessings, and safety. By showcasing their names prominently on the gates of the celestial city, it acts as a constant reminder of God's steadfast faithfulness in keeping His promises to His selected people.
Since Israel was God's chosen people and the 12 tribes are on the gates, it may mean that God's people are those who, on the very entrance of the city, their names are known.