The war originated in the Cuban struggle for independence from Spain, which began in February 1895.
Spain’s brutally repressive measures to halt the rebellion were graphically portrayed for the U.S. public by several sensational newspapers engaging in yellow journalism, and American sympathy for the Cuban rebels rose. So the explosion of the US Maine battleship and sympathy for the cubans.