In the US, a typical manager earns some amount more than the people they manage. As a result, the average software engineer earns significantly more than the average non-engineering manager, and more than many engineering managers.
And in the US, doctors and lawyers are not comparable to software developers for two main reasons: they have significant legal duties towards their clients (and must carry malpractice insurance as a result), and it is a serious crime to practice medicine or law without a license (which is granted by the people already in the field). Doctors and lawyers typically have further education, as well, which is not required for software developers. We also hear chronic complaints about doctor shortages, too -- but thankfully none for lawyers :) The kind of doctors with the worst shortages are "primary care" doctors, rather than specialists and surgeons, who also make much less money than the specialists, and I think in the same neighborhood as software developers.