There was a wide range of factors that motivated Europeans to colonize Africa in the late 1800's. The most important purpose of the colonies was an economic one. European countries needed resources to drive the industrial growth that was occurring across the continent. Africa had vast resources that could be acquired to make the European powers wealthier. These resources included gold, diamonds, rubber, petroleum, copper, and iron ore. Africa was also attractive because nations could establish exclusive markets for manufactured goods in the colonies. Success in capitalism depends on resources and markets, and the establishment of colonies provided both.
There was a component of racial superiority that drove the quest for colonial dominance in Africa. Europeans felt that they were a superior group and even suggested that colonizing Africa would be a benefit to its inhabitants. The idea of modernizing and converting them to Christianity was somehow believed to be beneficial to Africans. You only need to consider the history of the Atlantic Slave Trade to understand the racism that existed in Europe during the period.
The acquisition of colonies was also a consequence of fierce national rivalries that existed in Europe at the time. Britain, France, Germany, and other powers on the continent did everything they could to get a leg up on the competition. Acquiring land in Africa could give them a strategic advantage over their rivals that would reveal itself if a military conflict were to occur. Often times colonies were acquired because of their strategic location for trade and military expansion. As the decades after the slave trade went by, nationalism increasingly became a factor in the acquisition of colonies in Africa.