First of all, we should note that the struggle for civil rights for African Americans is, for the most part, over. African Americans have all the same rights as other Americans. The real struggle that continues is for African American economic opportunity, for less poverty, and for things like that which are not really connected to civil rights.
The length and difficulty of the struggle came from the fact that slavery existed and from the fact of the racism that helped cause slavery and which was strengthened by slavery. African Americans were enslaved for about 250 years in the United States and the British colonies that preceded the formation of the US. This meant that they were, for all of that time, unable to build up the kinds of communities and institutions that free whites were able to build up. They were put far behind whites in economic, social, and political terms.
Racism fed into slavery and resulted from slavery. After slavery ended, racism persisted. This was the main cause of the Jim Crow era. Racism made it very difficult for whites to accept the idea that blacks should have equal rights. It also led to segregation and discrimination that helped to cause the poverty that afflicts too much of the black community today.
Slavery and racism, then, contributed mightily to the problems that have made it hard for African Americans to gain civil rights and, more importantly, to gain true equality in the US.