What is the effect of the change of setting in Part 2?
If you remember, in Camus' short story "The Guest," the Arab stands at the crossroads of freedom and prison. Given a choice, ironically, he walks toward prison. This is Camus' assumption regarding most people: they choose imprisonment and death; rarely, if ever, do they cash in on freedom.
In The Stranger, Meursault is different. He is Camus' absurd hero: he loves life, hates death, and scorns the gods. Whereas Part I of the novel focuses on Meursault's love of life (swimming, sex) and simple pleasures (smoking, eating), Part II focuses on his hatred of death (being imprisoned) and scorn for the gods (the expected guilt that organized religion and the court system demand).
In Part II, Meursault's imprisonment, trial, and execution are not met with much anguish on his part. Yes, he scorns the system, but he does not despair or make excuses. He states, at the very end, he would live his life over just the way he did the first time. He has no regrets. Regarding his mother's death, he says, "Nobody, nobody had the right to cry over her." We must assume he feels the same way about himself.
He doesn't regret not crying at his mother's funeral. He doesn't regret killing the Arab. He doesn't regret saying he believes in God to save his skin. As an absurd hero, he knows he lives in an absurd universe, and he stands behind his choices, even if they lead to an absurd death. By doing so, he rises above his punishment, like the great absurd heroes of Greece, Sisyphus and Oedipus. (See Camus' wonderful essay, "The Myth of Sisyphus").
As far as Meursault is concerned, he is a stranger wherever he goes.
The irony is that the change of setting (from the beach and physical freedom to prison) has no lasting effect on Meursault's mental state. He is still free mentally speaking. In other words, he still has his free will and the ability to make sense (or not) of his situation. It would be better to say, he has the Absurdist disposition which allows him to accept his physical surroundings of prison with the same indifference he would with the surroundings of the beach. He even mentions that a man could spend 100 years in prison if he'd had one day of freedom out in the world (this does imply, however, that one must experience at least some physical freedom in order to remember and mentally practice it). Freedom, for Meursaultis mental.
He does miss things that his physical freedom provided: women, cigarettes, etc. His indifference is based on the idea that he accepts the absurdity of searching for meaning in the meaningless universe. Neither religion or any real sense of community/humanity evoke him or offer any solace. However, despite his mental agility at remaining so stoic, a sense of brotherhood with humanity does get to him occasionally. It seems like common sense that it is normal for him to feel emotional at times when he's confronting his own death, loneliness and so on. But this is an Absurdist novel. So, iironically, it is these moments when he feels absurd and the moments when he's indifferent (when the setting is arbitrary): that's when he feels at peace.