It can be used to refer to a preceding statement.
"If they [the immigrants] are integrated with the local population (1), [ preceding statemente ]
(2)IT will be better for everyone". [without "it" we could make the sentence "will be better for everyone if the immigrantes are integrated with the population
". So, in bold/italics the preceding statement.
Jack was maltreated by his uncle (1); and he could not forget
all his life.
Thus, in (2) it
refers to the fact that "Jace was maltreated by his uncle. So, you avoid repetition.
If you want to read more about the topic "'IT":https://www.englishgrammar.org/impersonal-pronoun/