Well, several things will make certain parts more expensive. If you are looking at Dura-Ace or Record stuff, those lines are superlightweight. Between exotic metals and carbon fiber, and exotic designs (to maximize strength at minimum weight), they cost a lot to design and make.
Ultegra and Chorus, OTOH, aren't quite so super-light, but are designed more with reliability in mind. On cheaper lines, many moving parts are made of plastic. Better lines have these same parts made of metal. Sometimes you also get things like composite-hardened jockey wheels, or other such expensive processes desingned to make the life of a fairly light component survive longer. Also, better bearings cost more money to make.