Dreadlocks as a hairstyle started in the Caribbean out of the Rastafarian movement. Rastafarianism has a complex history because it is not a religion, but more of an ideology–a way of life. It also has deep ties to Christianity, as some Rastafarians view themselves as descendants of ancient israelites and stories of being persecuted and the chosen ones are similar. In the 20th century the movement emerged and towards the ending of the century was popularized by reggae artists such as Bob Marley. Some Rastas state that Rastafari is concerned above all else with black consciousness, with rediscovering the identity, personal and racial, of black people.
Dreadlocks enter the story because it is one of the few hairstyles that affirm black identity in a bold way. Some see it as a symbol of strength linking it with biblical references to Samson, while others see it as a symbol of rejection of social norms. Most importantly, dreadlocks are an easy identifier for Rastas to distinguish themselves from the greater public. Today, dreadlocks still hold tremendous significance for Rastas but have also entered the mainstream for non-Caribbean Black people and other cultures overall.
Fun fact: I had dreadlocks up until I was 18, I am a vegetarian and my name comes from Rastafari!