Why do humans live in groups

1.The cause of the gregarious
Logically speaking, there may be two sources of human gregarious.
One possibility is that the ancestors of humans inherited the social habits by inheriting them. After all, most primates are gregarious.
Another possibility is that after human speciation, natural selection will retain human beings with gregarious habits and eliminate those without gregarious habits, thus making gregarious living a universal adaptive choice.