Thalidomide was a sedative discovered to be effective at treating the symptoms of morning sickness. Because it is chemically racemic, thalidomide consists of two molecular isomers that are mirror images of eachother. One of these halves inserts itself into biological processes—I don’t think we know how, exactly—and adversely affects child development, leading to birth defects.
You are correct-a drug called phenergan was/is used to replace it for a time-also causes sleep/drowsiness, but I heard there was some doubt about the safety of that one, too. In my world, pregnant = no drugs-have some crackers and chamomile or ginger tea.