Ever spend a lazy day on a boat or raft, drifting up and down with the gentle waves?
When you lie down to sleep that night, an odd thing happens. Close your eyes and the bed seems to be rocking, up and down, just like the boat.
This phenomenon has more to do with your ears and brain than it does with your bed. Your inner ear contains your so-called "vestibular organs," which help you maintain your equilibrium. These organs are basically fluid filled chambers with motion sensitive cells inside. When you're on the water, the fluid in these organs sloshes around as the waves push you up and down.
Climb aboard a boat and you're very aware of each wave; then you get used to the motion.
Your brain notices the same motions repeating inside those vestibular organs. Through a process called adaptation, your brain takes this repeating pattern as its new equilibrium. This is what happens when a sailor gets "sea legs" and is able to walk around on a rocking deck without losing balance.
Step onto dry land again, and your brain is still thinking that up and down motion is the norm. If a sailor has been at sea for months, he or she will probably stagger around the dock a while until the brain adopts a new standard of equilibrium. It'll be easier for you, because you've only been on your raft a few hours. Lie down to sleep, though, and in the absence of other stimuli your brain might still confuse rocking wave-like motion with steady equilibrium. Your bed rocks you to sleep until your brain adapts again.