Daraprim works by preventing parasites from producing necessary proteins, thus stopping their growth and reproduction within the body. It targets the parasites while sparing human cells, making it an effective treatment against infections like toxoplasmosis and malaria.