It is a social construct to try and keep everyone at peace.
The alternative would be a society with fault lines along racial and religious beliefs. And this would most likely lead to conflict.
So, if you don't want conflict, then you need to integrate in some ways.
You don't want to have identities develop and take hold. At that point it gets complicated.
For instance, in Brazil, once you know you are a person confined to live in favelas forever, then you participation in the broader society will be very limited. And with that the regard for the rules of the larger society.