The most well accepted and common reason for this unwanted behavior is dominance. Dogs will commonly hump any living thing, including your leg or another dog, to assert their position with that individual. This is a perfectly natural behavior, but should not be encouraged because one, it is incredible embarrassing when you are sitting getting to know your neighbor and your dog starts to hump your neighbors leg, and two, it could cause a scuffle or fight between two dogs, seriously, do you want a stranger welcoming you that way?
Some socially awkward dogs will not know how to interact with other dogs, and may take out their frustration by humping the other dog. This too should be discouraged by distracting your dog and showing him or her an appropriate way to play.
Reason three is simply out of boredom. If your dog doesn't go for daily walks and get adequate exercise, they will more than likely find an outlet for that energy and frustration, and that outlet might unfortunately be with your pillows. If this is the case, make sure your dog is getting at least two-twenty minute walks a day, and has enough (chew) toys to keep them entertained.
Probably the most obvious reason for humping, especially with females in heat, is due to sexual frustration. If your dog is not fixed, GET THEM FIXED! And your problem will more than likely be solved, not to mention you will have a much healthier and emotionally happier pet.
The last reason that I would like to point out is simply and uncontrollable urge to twerk when exited. Who can blame dogs when humans do the same thing? Often times puppies and young dogs will so called 'twerk' when they are excited, such as playing or eating or simply walking across the room. This is a completely normal and uncontrollable way for your puppy to practice behaviors key to their evolutionary survival. If you have a serious problem with this, you can remove your puppy from anything that might be getting them exited and calm them down. But for the first few months my lab puppy would twerk whenever I called him to me, and luckily he grew out of it, no harm done.
Humping is a behavior that should probably be discouraged as to make other dogs and people happy, and is fortunately very easy to redirect your dog from doing.