I ask this in good faith. Thanks.
First we need some context:
As everyone knows, South Africa pre-Colonialism was majority African, made up of numerous different tribes such as the Khoisan, Xhosa, Zulu and Sotho (to name a just a few). These tribes were not friends to say the least, and were often warring with each other as they had numerous physical, cultural, linguistic and other differences. South Africa, like much of pre-colonial Africa, was made up of tribes that varied differently in life style, with some being a settled group while others were semi-nomadic (like the San tribe in South Africa). They were not a United group by any means. South Africa is also an incredibly large country, falling just outside the top 20 largest countries, and around 6 times larger than the U.K.
All this means is that when the Boers (Dutch Settlers) arrived in South Africa there was a whole lot of land that they could inhabit. The Boers, now called Afrikaaners, initially settled in places like Cape Town. The area around Cape Town Pre-Boer were a nomadic group called the Khoekhoen who due to their nomadic lifestyle, put up very little resistance to Dutch Settlement there. When the British came along to Cape Town the Boers migrated deep into the South African inlands to escape the British, these Trekkers would set up their own communities and townships deep in the heart of South Africa. Cities such as Johannesburg had very little settlement in place already (there had been a couple villages and communities but they had been destroyed by a tribal war before the Europeans had reached that area) and grew as a result of a Gold Rush. This Gold Rush was mainly partaken by White Europeans looking to make their fortune prospecting, with very little African involvement.
So to answer your Question:
When the British began having a vested interest in South Africa at the start of the 19th century, it was because they didn’t want the French to have it. It was also an extremely useful asset as all ships travelling from Europe to the far East had to go past Cape Town (which was Britain’s earliest colony there) to get to Asia as the Suez Canal would not be built for over half a century. The 1810s and 1820s saw a large number of migrants leave Britain to go to Cape Town and the surrounding area as it would help deter raids from loca tribes. When it was found that the heart of South Africa contained a vast amount of mineral wealth, the British would expand their interests in land and make South Africa a colony over the course of the 19th Century until South Africa’s (partial) independence in 1909. The British we able to oppress the native Africans as they had superior guns, weaponry and tactics. This meant the locals kind of had to do what they said.
South Africa as an independent dominion existed between 1909 and 1961 (but they became fully sovereign in 1934) and then as a fully independent state from 1961 until now. These various governments were able to impose apartheid for numerous reasons.
The Native Africans were not a unified body, whereas the white Europeans (who made up 1/5th of the population) were United in their racism (for the most part of course there were a couple of exceptions) and desire to undermine the Native Africans. The Native Africans never were not able to join forces against the abhorrent regime until much later.
The White Europeans held all the military power in the form of Guns, tactics and equipment so if there ever was a unified African rebellion it would have been put down.
There was little foreign support for the Native Africans as well as all developed nations that could have helped were White European nations that sympathised with the White Europeans. This would change further along as people began to realise the horrendous nature of Apartheid and began condemning South Africa, with the British Rugby team famously refusing to play the South African Springboks.
The White Population and the Native African Population were already separated. In the early days of Independent South Africa, White Europeans either lived in the large cities or is rural communities that were very ethno-centric, whereas the Native Africans lived in their own rural communities or as Semi-nomadic or purely Nomadic groups. There was very little mixing so for all intents and purposes segregation didn’t need to be enforced in the early parts of Independent South Africa, as the two groups hardly mixed. When the groups did mix it was usually when a White European hired a Native African to be his servant.
Native Africans began noticing that their old tribal lifestyle was no longer compatible in the South Africa they lived in, so moved to large cities such as Cape Town. In Cape Town they were forced to move to places called “Townships” which were essentially slums in the outskirts of the cities not disimilar to Brazilian Favelas. Here they would live an a community of only other Native Africans and commute daily to work for their white employer. This was a way to keep White people segregated from the Native Africans.
White people held all political power. It was White people that were able to control where in the cities Native Africans lived and were able to impose their racist laws and ideals onto them. White people were able to hire all white police forces that specifically targeted Africans who were concentrated in the Townships. Meaning that protests and dissent could easily be jumped on and stopped.
Africans were at a huge economic disadvantage. The Africans that lived rurally were mostly ignored and there suffered as a result. The urban Africans worked low paying jobs so they mostly lived extremely humbly in deprived conditions. The schools for Africans were a lot worse, so they left without the skills to compete with White People in the professional work force.
All of these and reasons, among others, contributed to how South Africa, with only a minority of White People, could subjugate the Native Africans in South Africa and force them to endure one of the most horrendous regimes seen in recent history.
To offer another example based on your premise: Before the Civil War, South Carolina (the first state to secede over a perceived threat against the expansion of slavery) was a majority-Black state. Nearly 60% of its population in 1860 was Black, though of course the vast majority of them were enslaved. The United States as a whole might have been white-majority, but the states with the most investment in slavery were either white-minority or close to parity, and a similar demographic held in the decades after the War. It was this fact that led to many of the draconian measures that the slaveholding elite imposed, as well as racial segregation and "Jim Crow" laws passed after Reconstruction. They knew that if a slave uprising ever took hold, they wouldn't stand a chance due to the sheer numbers. In their case, even though they were a minority, the slaveholders and their political allies held the reins of power, and they did everything they could to keep a grip on it. "Jim Crow" was possible because white landowners and politicians kept a firm grip on their power and most politicians of the North were willing to look the other way, but they felt it was required because they were outnumbered in their home states.
Sources:
Michael Trinkley, "South Carolina – African-Americans – Slave Population," South Carolina Information Highway, Accessed 7 December 2022, https://www.sciway.net/afam/slavery/population.html.
Sharples, Jason T. The World That Fear Made: Slave Revolts and Conspiracy Scares in Early America, Philadelphia, Pennsylvania: University of Pennsylvania Press, 2020.
McCurry, Stephanie. Masters of Small Worlds: Yeoman Households, Gender Relations, and the Political Culture of the Antebellum South Carolina Low Country. New York, New York : Oxford University Press, 1995.