It was that war that enabled the Empire to acquire its imperialist domain in Cuba known as Guantanamo Bay, which is now the Empire's premier international indefinite-detention prison, torture center, and kangaroo judicial system.
The late 1800s were a time of worldwide empires. Great Britain, France, Spain, and others were empires, possessing and oftentimes brutally controlling people in faraway colonies. Although the U.S. Constitution had called into existence a limited-government republic, by the time the latter part of the 19th century had arrived, many Americans had been swept up in the pro-empire fervor, owing largely to the Progressive movement, which was also influencing America toward embracing the worldwide move toward socialism and interventionism. The Progressive idea was that in order for the United States to become a great nation, it needed to become an empire, just like other empires.
In 1898, Cuba and other possessions of the Spanish Empire were fighting for their freedom and independence. Since this was a time in which U.S. officials were still following the Constitution's declaration-of-war requirement, President William McKinley sought and secured a declaration of war against Spain, with the ostensible aim of helping the Spanish colonies win their freedom and independence.