James Weldon Johnson does not give his narrator a name because the narrator writes the book to explain what he calls the greatest secret of his life--that he is an African-American man trying to pass as white. The narrator states in Chapter 1 that he was born in Georgia, but he does not name the town because "there are people still living there who could be connected with this narrative." The narrator, living in the years after the Civil War, fears that his true identity will be discovered, so, to continue living as a white man, he resists giving his name and remains anonymous.
In a larger sense, by making his narrator anonymous, the author is also suggesting that the narrator has had to give up much of his identity to pass as white. At the end of the book, the narrator says, "I cannot repress the thought, that, after all, I have chosen the lesser part, that I have sold my birthright for a mess of pottage." In other words, the narrator feels that he has given up his identity and his talents for something--a white identity--that is not worth very much in the end. His anonymity underscores this loss of identity.
The narrator does not reveal his name supposedly to protect the innocent, but really to create an effect of the novel being a real autobiography.
The narrator is a black man who is “passing” as white. Therefore if he writes an autobiography revealing the color of his skin his wife and children will face retaliation.
As my outlook on the world grew brighter, I began to mingle in the social circles of the men with whom I came in contact; and gradually, by a process of elimination, I reached a grade of society of no small degree of culture. (ch 11, p. 92)
The narrator comments that his situation appeals to his sense of humor. He is popular among his white friends, but if they knew that he was black they would not feel the same way about him. Not knowing his name increases the distance between the reader and who he really is, enhancing the persona of the narrator instead.