Let's turn your analogy around. Are you complaining that there aren't more hobbyists dabbling in medicine without licenses nor viable careers? Or that society doesn't actively pursue and arrest programmers for doing similarly...?
There are countless developers making successful careers out of it, just like medical doctors. In addition, there are many more successes on a spectrum that includes the programming equivalent of GPs, nurses, paramedics, pharmacists, drug store clerks, pot farmers, herbalists, dietitians, mothers dispensing band-aids and kisses, and aged boy scouts who happen to be in just the right place at the right time to save someone's life with first-aid.
There are countless activities in life that may or may not have viable business plans behind them. What sets programming apart from doctors and other service-based industries is that our work product is trivially replicated and shared by others. Look to literature, music, theater, and cinema for metaphors about the roles and compensation of content producers in culture and society.