In the 1820s when Spain still retained control of Cuba
african and afrocuban slaves or the indentured labourers who were brought from china in large numbers in the mid century,slaves continued to be brought in illegally until the early 1860s
The sugar industry brought considerable wealth to Cuba and the island was seen as valuable by Spain.
However, many Cubans resented Spanish rule. To a large extent, all important jobs were filled by officials, sent out from Spain and Cubans had little say in the running of their own island. Spanish officials from the governor down, were corrupt and Cubans couldn't get anything done without bribing someone. The smallest opposition was likely to be harshly suppressed.
Many Cubans were involved in what became known as the Ten Years' War(1868-1879), which they fought to secure their independence. However Spain did not want to lose its valuable colony, and sent large numbers of troops to the island.
Neither side was able to win so a settlement was agreed. Cuba remained a Spanish colony, though Spain introduced reforms such as slavery ending completely in 1886, but this was not enough and the opposition to Spanish rule remained strong.