A similarity between the two books is that they both involve restrictive societies and prejudice.
In To Kill a Mockingbird, the town of Maycomb is highly prejudiced against African Americans. Mayella Ewell can’t have a relationship with Tom Robinson not because he is married, but because he is black. Even though he does not return her affections when she tries to kiss him, he is the one who is put on trial, convicted, and eventually shot.
Atticus explains that Mayella and Tom were the victims of society’s code.
She did something that in our society is unspeakable: she kissed a black man. Not an old Uncle, but a strong young Negro man. No code mattered to her before she broke it, but it came crashing down on her afterwards. (ch 20)
As a result of this code, Tom was targeted and lost everything, including his life eventually.
Similarly, Hester is also isolated by her society in an unfair way. She does commit adultery, but there is no similar victimization of the men when they do so.
Hester Prynne [wore that] SCARLET LETTER, so fantastically embroidered and illuminated upon her bosom. It had the effect of a spell, taking her out of the ordinary relations with humanity, and enclosing her in a sphere by herself. (ch 2)
As a result, Hester is alone for the rest of her days, with her baby and later child. No one else associates with her on an even level, all because she committed adultery and broke society’s code.
In each case, the person who is underrepresented by society suffers the consequences while the person who is more to blame suffers much less. Until the trial, no one knows Mayella kissed Tom and he did not rape her, but it does not matter by then. They can’t take his word over hers. Hester keeps Arthur Dimmsdale’s identity a secret, and she is the one who is ostracized. Despite the disadvantages the men face, in each case the women have no power and no recourse.
What comes immediately to mind is that both "To Kill a Mockingbird" and "The Scarlett Letter" involve prejudices that permeate the larger society at the expense of individuals, and that ignorance of the masses is the order of the day. Racial prejudices that are prevalent in "To Kill a Mockingbird" can be compared thematically to the gender biases at the heart of "The Scarlett Letter." Blacks were treated as inferior beings in one story, and women, especially those alleged to have undertaken adulterous affairs, are treated as inferior beings in the other.