First of all, let us note that Weyler put the Cubans in concentration camps before the Spanish-American War, not during it. The concentration camps were one of the things that helped to excite American public opinion and cause Americans to want to go to war with Spain. They were not something that Weyler did because of the war.
Weyler put Cubans in concentration camps to try to reduce support for the Cuban rebellion. Weyler was in charge of trying to suppress the rebellion that was going on in Cuba. Many Cubans wanted independence from Spain and Weyler was fighting against them. The Cuban rebels were largely guerrilla forces. Their members were part of the community as a whole and they gained a great deal of support from the community. Therefore, Weyler set up the camps. He wanted to put much of the population in the camps so that they could not support the rebels. If they were in the camps, they could not, for example, provide the rebels with food. Thus, the point of the camp was to keep the population of Cuba separate from the rebels so that the rebels would have a harder time maintaining their rebellion.