One theory that I have always found compelling from more recent psych on this is the uncertainty theory wrt to intergroup cohesion/formation. Basically, just like with the "just world hypothesis," we have a lot of very deep reasons that we want to resolve "group uncertainty." IS something a cohesive group? DO we share a common fate? IS this my ingroup? We actually navigate highly ambiguous group situations a lot, but people show quite a bias to resolve that uncertainty with entitativity