Peter gives an example of Lot, whom God rescued out from among men who deserved punishment.
the sensual behavior of lawless people
"the immoral behavior of people who broke God's law"
that righteous man
This refers to Lot.
was tormented in his righteous soul
Here the word "soul" refers to Lot's thoughts and emotions. The immoral behavior of the citizens of Sodom and Gomorrah disturbed him emotionally. AT: "was greatly disturbed" (See: rc://en/ta/man/translate/figs-synecdoche)