Fear is the emotion behind hatred. Fear comes when you are threatened either physically or emotionally or psychologically.
When you do not have the basic requirements for survival and safety and belongingness and where there are huge inequities then fear turns into hatred.