Carbon dioxide is necessary for plants for the process called photosynthesis. This process converts carbon dioxide from the atmosphere into glucose molecules. which serve as a source of food for the entire living system.
But increasing concentration (more than normal) of carbon dioxide is harmful and considered as a pollutant. Because it absorbs and retains heat very well, and therefore, can contribute to the greenhouse effect, which is basically global warming.