It is a demand a supply equation. Right now there is a lot of demand for software engineers and they earn a premium. Noone can guarantee that the situation is going to be same for say next 20 years.
medical profession is steady and doc. earn a lot more when they get necessary experience and build up a reputation. Over long term, medical profession is a safer bet.
Also the obesssion of our parents and society for the doctor tag lead to the downfall. There are so many self finacing colleges and people are willing to spend any amount to get a seat, irrespective of the salary expected.