21:27 Nothing impure will ever enter it, nor will anyone who does what is shameful or deceitful, but only those whose names are written in the Lamb’s book of life.

Nothing IMPURE

Other translations use the word 'defiled' or 'unclean' instead of 'IMPURE'; so let's look at what 'defiles' a person or makes a person 'unclean':

his words
Matthew 15:1-11-18-20
with whom he worships or what he worships Acts 21:27-28-30
the eternal cleansing of Christ's blood is denied
Hebrews 9:11-13-14

will ever enter it, nor will anyone who does what is shameful or deceitful,

Out of the list of persons who are in the lake that burns with fire and brimstone (verse 8), all are shameful or deceitful. Furthermore, if you deny 'doing anything' in the list (above 'liars'), and then do them, that becomes a LIE.

The abominable show by their deeds that they don't BELIEVE in Jesus Christ (Titus 1:15-16). The liars because they are the opposite of THE TRUTH (one of the names of Jesus Christ - John 14:1-6-11) can't come anywhere near to 'IT', the new Jerusalem (THE CITY). THE TRUTH and His wife live in the new Jerusalem (verse 2).

but only THOSE WHOSE NAMES ARE WRITTEN in the Lamb's BOOK OF LIFE.

It is appropriate here to restate our understanding about the BOOK OF LIFE. Everyone's name is written into the BOOK OF LIFE at the conception of that unique life. As that life is lived, sin is committed by that life (Romans 3:21-23-31). The Lamb then erases that life's name from the BOOK OF LIFE (Revelation 3:5). The life, when it accepts Jesus Christ as Lord and Savior and holds onto that commitment (victorious - verse 7), has that life's name restored to the BOOK OF LIFE by the Lamb. It is our choice to be in the BOOK OF LIFE; it is Christ's choice of your eternal residency, all because of where your NAME is written. If your name is NOT in the BOOK OF LIFE, you are doomed (Revelation 20:15). If your name is in the BOOK OF LIFE, you are a resident (inheritor - verse 7) of the new Jerusalem, THE CITY.