A physician in antiquity and the Middle Ages would not have been an officer, and he would not have held a rank. Answering your question with high precision would be quite difficult, because medical practice underwent a great deal of change between 300 CE and 1550 CE. That said, there are a few generalizations I can give.
The first thing to recognize is that ancient and medieval medicine had two parallel traditions. One was a textual, theory driven tradition that followed Galen, and the other was a practical one, learned by doing rather than study (what would later be recognized in the more structured apprentice/master relationship). This led to a distinction between the lettered, professional physicus and the practical, unlettered medicus.^1
A poor soldier would not be able to afford the cost of a professional physician. A doctor trained in Galen would likely service only high ranking officers, who were very wealthy. For example, it is suspected that Antistius was Caeser's personal physician. The more practical healers, which would later become known as barber-surgeons in the Middle Ages, would likely treat the more common soldiers.
During the early Middle Ages, this educated, lettered physicus disappeared in Western Europe--books on medicine never survived the period of translation between 400 and 600 CE.^2 Following this period, medicine became a very fragmented discipline. When considering the military, it is most likely that what medical aid might be provided would come from the monks or priests who often accompanied these companies.^3 Monks were the closest one came to bookish, theory driven medicine during the early Middle Ages, and were often very knowledgeable in herbs and medicines.^4
Again, your question spans a 1000+ plus span of time, so I am responding very generally. I am happy to answer specifics if you have more pointed questions.
This is a lengthy post that goes into a lot of detail about the advancement of medicine as a science and a profession, but I believe those angles are crucial to understand when considering the burgeoning status of medical officers across history.
If you're interested in this subject, I would recommend this book which offers a summary of military medicine from the Middle Ages through the modern age. Like /u/YourPrivateHistorian said, medical care was expensive and accessible only to wealthier clientele through the Middle Ages. In addition, medicine also had to become more effective and professionalized before it could play a truly integral (and later prestigious) role in the military. Thus, the two reasons I would cite for the growth of military medicine are:
(1) Medicine itself became more effective. This seems like a simple answer, but until medicine was advanced enough to save people from life-threatening wounds and war-related diseases, it would not have been necessary to offer expansive medical services on the battlefield. Why staff the battlefield with physicians who could only, at best, offer comfort measures that non-skilled individuals could also deliver to others? (like alcoholic drinks to dull pain, for example.) So medical science needed to reach a point where it could offer observable, impactful solutions for war-related injuries and illnesses. Surgeons like Ambroise Paré (France, 16th century) pioneered new techniques for treating gunshot wounds; he and other early military physicians/surgeons accompanied militaries almost like scientists. These physicians would: use battle wounds as opportunities to test new surgical interventions, develop ambulance and evacuation techniques, observe new types of wounds and fractures, and learn about anatomy in a practical setting. Other non-military specific advancements through the 19th century, like public health practices to ward off infectious disease, antiseptic surgical practices, improved knowledge of anatomy and physiology, and the discovery of anesthesia (ether and chloroform being among the first), greatly improved the efficacy of medical practice. As physicians and medical scientists developed techniques for understanding, managing, and treating complex war injuries and other conditions, so too did their inclusion in European militaries become more solidified. By the 18th century, physicians and surgeons were being given military warrants to serve as medical officers (ex: in the British Navy.) That touches on the second point...
(2) Professionalization was critical. The other important development was professionalization, i.e. the creation of a standard set of practices, training, and skills required of medical practitioners by a group of their peers. By the 18th century, physicians and surgeons (who were separate professions until the 19th century) had established early professional guilds which allowed them to standardize practices and license new members of the craft. Professionalization was critical because it controlled for the quality and rigor of physicians' training to some degree: such that militaries could build medical corps knowing that the physicians they employed would be properly trained, effective caregivers (again, to some degree: medicine was very heterogeneous even into the 19th century, as I describe here.) At the same time, militaries also created their own professional departments to manage the hiring of medical officers and regulations around medical and health practices, like the Sick and Hurt Board of the Royal Navy. Not only did professional organizations regulate individual practitioners, they also significantly increased the power and prestige of physicians/surgeons by lobbying for laws that limited homeopathic and non-traditional medicine and by fighting for stringent prescriptive and medical authority over patients. In other words, medical professional organizations increased the prestige and power of practitioners outside of the military context alone, though this lead to a broader cultural shift that is reflected in the high status of military physicians that you referenced.
TL;DR: As medical science developed and as the medical profession became more defined between the 17th and 20th centuries, so too did physicians and surgeons become more integrated into the military. Likewise, as they became more effective at treating complicated and life-threatening conditions, and as they formed professional standards of practice, physicians/surgeons' prestige as a profession increased, which was ultimately reflected in the high status they received as officers (first warrant, then commissioned) in European militaries.