Cognitive biases serve an important purpose, that is why they got to stay with is and have been with us for millennia.
Yhey defended us from predators, helped us made “life or death” decisions, helped us make quick value judgements to better decide for what was better for us and our future, helped us define our world as quick as possible in order to have a fighting chance to survival.
They still help us live a better, simpler life where we don’t have to “reason” everything.
Since biases are always there with us, they don’t necessarily “arise”, they merely get manifested when they poorly extrapolate to more modern situations, so the biases that helped us gather in groups and societies (i.e. “Ultimate attribution error”) now make us more eager to distrust a group we are not associated with, for better or worse and beyond more “reasonable” reasons at hand.