Taking painkillers, especially opioids, during pregnancy can affect the baby by increasing the risk of pregnancy loss, neonatal abstinence syndrome, breathing difficulties, and premature delivery.