When you reach out with your arm and touch something, there are an infinite number of ways you could do it. Importantly, you could have your elbow pointing down, up, sideways, or anywhere inbetween. You could have your fingers straight or bent. The inverse kinematics we have seen so far could come up with any of these solutions, because it has no reason to choose one over the others, as long as the target is reached.
All we need to do, to make things look comfortable, is to impose a small 'penalty' for uncomfortable or unnatural positions. It depends how you define these things, but for something like a human arm, natural suggests lazy. I don't want to lift my arm any higher than I have to. Therefore, we can add to our error function, a cost for the centre of gravity of the arm.
How to control the joints of a robotic arm so the endpoint (or hand) goes where you want it to go. This page also talks about fine tuning the control algorithms to avoid obstacles or awkward joint positions.