Why do specialists earn more than generalists?

And have more free time? And throw the best parties?

Specialists specialise because they can do special work.

The standard example is a doctor.

A GP starts work early, finishes late, never knows who is going to walk through the door and has to deal with angry and upset patients who do not want to listen to the advice given.

A heart surgeon works few hours, has a long waiting list and can pick and choose their patients, gets tons of highly paid private work and is regarded as one of the best and brightest in the medical profession.

Why is this?

Because the GP has a wide, general, knowledge, so by definition, has to accept anyone. Whereas the heart surgeon has a deep, specialist, knowledge, so gets referrals from other doctors who don't know as much as them

Now maybe the medical profession is a bad example, because it's a vocation. But then, to some extent, coding is a vocation to me; I want to write the best, well-structured, most elegant code I can - whilst still solving my clients' problems. Which approach do you think will allow me to do that?