What was the natural sleeping posture of humans before beds and pillows were invented?
Probably the fetal position as it makes using one's arm for a pillow easy and conserves body heat while protecting vital organs. Laying somewhat crouched on one side is the way you see people mostly sleep when camping outside without tents or sleeping bags when they're most vulnerable. Curled up together in heaps with children in the middle and the biggest, toughest adults on the outside in cold weather was standard while of course in hot weather, being scattered and sprawling with the most surface area exposed for sweating is more of the norm. While caves were much less common as human habitation than imagined, good caves being rare and either too small or too big, digging a pit house is very old. It's a deep hole for multiple people to live in over many years with the ground's insulating effect keeping it at around 50 degrees regardless of surface weather. A roof of interlaced branches and leaves covers the pit. The pit dwellings sometimes have an excavated shelf for sleeping on above the lowest level where a firepit, trash, etc. would be, repeated in much later dwellings up through 20th Century trench and tunnel bunkers.
While a bed with a coiled spring mattress and boxspring set is a late 19th Century innovation, a mattress or big sack stuffed with horsehair, goose feathers, or straw was common for centuries before that, the sack of straw particularly. Making a mattress that's a suspended set of ropes (or leather straps) tied together to support the body in many places at once and knotted into a wooden bedframe goes back I think to before Roman times and really isn't a bad solution. There's a lot of health benefits to being suspended some inches from the floor for where pressure is put on the back and joints as well as being less easy to reach for insects, rats, mice, squirrels, dogs, and water.
Fresh grass, pine tree small branches or fresh leaves go back hundreds of thousands of years as some of the oldest burials found suggest a bed of these was common. A larger mound for a pillow is common too, the span of the shoulder blade to the neck and head really appreciates a pillow's additional support.
Covering up with more leaves or branches helps but man was using tanned animal skins for that, generally with the fur/hair left on and that side inward against the human skin as the dense coat traps a lot more air (like a modern quilt) for noticeably greater warmth. Laying on one or two animal hides over grass or straw piles with another one or two for blankets was standard for a long time, hundreds of thousands of years most likely and used by tribes in my region up to nearly a century ago.
I've slept on the ground in the bush more than most have had hot dinners. While I like love a good swag (Aussie bedroll), I've often done without it. At those times I found that scraping a small, half-fist-sized hole for my hip, and adopting the ‘recovery' or foetal pose to be quite comfortable.
Predators aren't necessarily a problem for sleep, especially if you've a dog or two. We are the lead predator though and have been for a long time, so few animals care to bother us. In times of danger we can sleep lighter and rely on our senses to alert us to significant change, just the same as many of us do now to the sounds of our children in the night. In the bush I'd wake a few times during the night to listen for the horse or camel bells so I'd know which direction to walk when retrieving them prior to sunup.
We've plenty of snakes, spiders and dingoes in the Outback, but I was never worried by any of them during the night. While I have heard the odd tale or two, they tend to avoid our scent and our wrath. Dingoes will look about the camp during the night without bothering anyone, unless there are dogs there which may keep them out. When we used to salt our meat and put it out overnight to cool, the camp would often be covered in dingoes tracks come morning, but no one was ever bothered by them. They were stealthy and didn't care for salted beef. Domestic dogs allow a sound sleep because with their better hearing etc, they make great alarms.
If you travel in provincial China you may not be able to find a soft bed, and many would be harder even than some good earth beds. A traditional Chinese bed doesn't allow a hole for your hip and can be less comfortable, for me, than sleeping on the ground. When I met my wife she was sleeping on bamboo floors, and I did too for a time. These too are less comfortable than sleeping on the dirt, but drier and better ventilated for the tropics.
I'm pretty happy now with our king-size bed which we share with one or more of our children. I often have less room on it though than I would if we all slept on the ground!
Al Jones has covered the topic quite well, but I'll just add one thing: Our nearest relatives, the chimpanzees, don't just sleep on hard ground but very carefully make nests in trees by folding in branches full of leaves. Many years ago I was able to watch similar behaviour while working with a large group of captive chimpanzees in a zoo. Every afternoon we provided fresh bedding material so when the chimps came in from outside they could grab armfuls of it and make their own beds. I used to love watching them as some of them put a lot of concentration and effort into it. Comfort seemed important.