Gripe water is a "medicine" used to treat colic in infants. To be clear, there is no scientific evidence that it works, and some variants may contain activity harmful substances. To be very very clear the original formulation, below, is just plain bad, and currently illegal in both the US and the UK.
Gripe water is not a traditional remedy, despite what many sources would have you believe. It was invented in 1851 by English pharmacist William Woodward, who noted that certain medications given to patients to treat fen fever and malaria also had the side effect of treating colicky babies. Broadly speaking, today colic simply refers to frequent idiopathic and inconsolable crying, but back in the day people assumed that was due to intestinal gas, and cures focused on helping with the digestive process.
Woodword's recipe included water, alcohol, sugar, sodium bicarbonate, and dill seed oil. With an alcohol content of 3.6%, larger doses could make a baby tipsy, which may have helped get it to sleep. Woodword's Gripe Water was trademarked, and is still sold today. In the 1992 the alcohol was removed, and in 1993 it changed from prescription to an over-the-counter "nutritional supplement".
Modern gripe water is sold by a number of different producers, each with their own formula. The most common active ingredients are sodium bicarbonate, dill seed oil, fennel oil, and ginger extract, although one must suspect that if anything actually helps to calm a crying baby, it is most likely the sugar. There is no scientific evidence to support the use of gripe water, and given the wide range of recipes and uneven application of regulation, it is probably wise to avoid the stuff.