The Monroe Doctrine was a policy that had its origin in the US in 1832, with the aim of fighting against European colonism in American lands. The US defined that they would not intervene in existing colonies but that they would consider any new movement (invasion or annexion) perpetrated by Europeans in America as an offence to the US.
President McKingley decided the intervention of the US in the conflict between Spain and Cuba, in which the latter was fighting for independence. In fact, since his decision the conflict was namd the Spanish-American war, as the US took the side of Cuba against the Spanish to end this share of European colonialism.
At first, the US stood apart of the conflict, but the sensacionalist news that arrived to the US showed how the Spanish were commiting atrocities against Cuban civilians. The US public opinion supported the intervention. Finally, the incident of the Maine, the US ship in Havana, whose explosion was attributed to the Spanish, was considered as a direct offence and triggered the arrival of US troops to Cuba. The Monroe doctrine supported interventions when the US was directly offended.