Check this article out. I think it's a very helpful explanation for the behavior.
The Dog Trainer : What to Do About Your Humping Dog :: Quick and Dirty Tips
While it may be unwanted by people - I'm hearing people say it's unacceptable behavior - I would have to disagree. Seems to me it's very natural and part of life for most animals.
Sexual behaivor isn't unacceptable or at least shouldn't be in my humble opinion - but like all things, there's a time and a place.
[And I don't think a human arm or a leg is ever the place

]
My two cents.