Four millennia ago an ancient Babylonian wrote down a lullaby sung by a mother to her child. It may have got the baby to sleep, but its message is far from soothing - and this remains a feature of many lullabies sung around the world today.

Deeply etched into a small clay tablet, which fits neatly into the palm of a hand, are the words of one of the earliest lullabies on record, dating from around 2,000BC.

The writing is in cuneiform script - one of the first forms of writing - and would have been carefully shaped by a Babylonian scribe, with a stylus made of reed, in what is modern-day Iraq.

It's a rather menacing lullaby, in which the baby is chastised for disturbing the house god with its crying - and threatened with repercussions.

Frightening themes were typical of lullabies of the era, says Richard Dumbrill, a leading expert on ancient music with the British Museum in London, where the tablet is kept.

They're like advice columns for babies Zoe Palmer, Musician

"They try to tell the child that he has made a lot of noise, that he woke up the demon, and if he doesn't shut up right now, the demon will eat him."

If this sounds more scary than sleep-inducing, it so happens that many lullabies - including those sung today - have dark undertones.

"Rock, rock, rock," begins one popular lullaby sung by the Luo people in western Kenya, before warning starkly, "The baby who cries will be eaten by a hyena," - an actual possibility in some parts of the country.

The well-known UK lullaby, Rock-a-bye-Baby, also contains danger, warning in the nicest possible way that the baby and cradle will drop from the bough of a tree.

Night-time has always been associated with darkness and fear and this may go some way to explaining the threatening themes in some lullabies, says Sally Goddard Blythe, author of a number of books on child development, and director of The Institute for Neuro-Physiological Psychology.

But all lullabies - even the scary ones - she says, are rooted in "love, tenderness and caring".

Many lullabies, regardless of the meaning of their words, possess a peaceful hypnotic quality. Others are mournful or dark, like a lament.

Some are "telling you the history of the country, or telling you how you should or shouldn't run your life - kind of like advice columns for babies," says Zoe Palmer, a musician working on a lullabies project at the Royal London Hospital.

Palmer works with new mothers at the hospital, as part of a group of musicians, helping them to learn and share existing lullabies - as well as creating new ones.

Lullabies belong to the instinctive nature of motherhood Richard Dumbrill, Archaeomusicologist

It's a very diverse community - with parents from China, Bangladesh and India, as well as Italy, Spain, France and Eastern Europe - but she has found that lullabies are remarkably similar across cultures.

"Wherever you go in the world, women use the same tones, the same sort of way of singing to their babies," she says. Many lullabies are very basic, she notes, with just a few words repeated again and again.

Rhythmically, there are shared patterns too. Lullabies are usually in triple metre or 6/8 time, giving them a "characteristic swinging or rocking motion," says Sally Goddard Blythe. This is soothing because it mimics the movement a baby experiences in the womb as a mother moves.

As well as helping a baby to sleep, lullabies may serve and educational purpose.

Singing with a baby is a natural and effective way of sharing new words and sounds, says Colwyn Trevarthen, professor of child psychology at the University of Edinburgh and vice-president of the British Association for Early Childhood Education.

Mother's voice: An 'acoustic bridge' A baby can hear sounds from around the 24th week of pregnancy - but they are muffled and much narrower in range than when they emerge in the outside world, says Sally Goddard-Blythe (4,000 Hz is the top end, versus around 20,000 Hz after birth). The mother's voice is described by Russian paediatrician Michael Lazarev as an "acoustic bridge" between the cocoon of the womb and the outside world. Babies hear sounds from outside, but the mother's voice is the most powerful sound, says Goddard Blythe, "because it's heard both internally and externally - with her body acting like the sounding board or the resonator of sound".

For example, a Swedish lullaby, Mors Lilla Olle (Mother's Little Olle), has eight different vowel sounds, in four rhyming pairs.

For decades Trevarthen has been studying how mothers and babies interact in the early months. His research suggests that babies are innately musical, and have an excellent sense of rhythm.

Even when a mother is not actually singing to a baby she tends to speak in a musical way, he says, with the notes and inflections of her words going up and down, and a clear rhythm.

What's particularly "astonishing" he says, is how precisely the baby responds - in coos and gestures - often exactly in time with the pulse and bar structure of her sounds. Baby and mother "get in the groove," he says, like jazz musicians improvising.

"Human beings are born with all these very strong human capacities for being expressive in time," says Trevarthen.

In the 1920s, poet Federico Garcia Lorca, who studied Spanish lullabies, noted the "poetic character" and "depth of sadness" of many of them.

One of the best-known traditional Iraqi lullabies, is a particularly sad one, about the heart-ache of missing relatives. It's often sung at funerals and ends: "What a pain in my heart. Oh my son, how I wish to hear from my loved ones."

Lorca's theory - which many researchers today would agree with - was that a large part of the function of the lullaby is to help a mother vocalise her worries and concerns. In short, that they serve as therapy for the mother.

We know that lullabies were deemed important enough to be documented by the Babylonians 4,000 years ago, but how much longer will they survive?

There are many factors that could threaten the continuation of the lullaby tradition - the array of gadgets to entertain and pacify a crying child, and the increased reliance on technology for communication, for example.

Perhaps the habit of singing is less a part of everyday life than it once was, where previous generations without televisions and computers would naturally come together to sing and share stories.

But my research on lullabies indicates they are still going strong - from Kenya, to Syria, to Morocco to the UK.

In a word... "Lullaby" derives from two earlier English words that were both used to soothe children - "lulla" and "bye". They were combined in the late 1500s to refer specifically to a song used to calm down children or put them to sleep. Source: Kory Stamper, Merriam-Webster

Archaeomusicologist Richard Dumbrill suspects there may be something intrinsic to the experience of raising a child which will guarantee the lullaby's survival in the future.

"The oldest lullaby is certainly when the first woman sang to her first child," he says. "I'm quite certain that lullabies belong to the instinctive nature of motherhood."

Reem Kelani, a British-born Palestinian singer, agrees.

"It's one of those universal things," she says. "Whenever I sing a lullaby, wherever I am in the world, there are always people who relate to it.

"It's the umbilical cord… and that's the exceptional power of a bedtime lullaby - it's timeless and it's forever."

Nina Perry was reporting for a BBC World Service documentary series on lullabies. Listen to The Language of Lullabies and Lullabies from the Arab World. Image of family in Morocco, Lily Al-Tai.

Additional reporting by Cordelia Hebblethwaite

You can follow the Magazine on Twitter and on Facebook