Why are the human knees and elbows bent in an opposite direction
I am no expert on comparative anatomy, but I will give this a shot. Please edit if you know more about this subject!

The configuration of opposing elbow and knee joints is a feature we humans share with large group of mammals. For example, below is an image of a shrew skeleton.



Opposing joints are course a major feature of mammalian anatomy, and there are many studies on its functions and advantages. Among other things, this configuration allows for characteristic gaits of mammals such as the gallop of a horse, and it allows mammals to rest with legs protected under their body. See this page for some basic information.

Neil Shubin's book Your Inner Fish on human evolution also discusses the opposing joints arrangement, noting that this is a "key feature that gives us the capacity to walk, one we share with other mammals". A preview of the book is here.

A quick literature search turns up many technical articles on this subject, such as this review series. I'm afraid the details are beyond me (again, experts please edit), but I think it's fair to say that there is plenty of evidence for advantages of this joint arrangement in mammals.