We carry out a first-principles atomistic study of the electronic mechanisms of ligand binding and discrimination in the myoglobin protein. Electronic correlation effects are taken into account using one of the most advanced methods currently available, namely a linear-scaling density functional theory (DFT) approach wherein the treatment of localized iron 3d electrons is further refined using dynamical mean-field theory (DMFT). This combination of methods explicitly accounts for dynamical and multi-reference quantum physics, such as valence and spin fluctuations, of the 3d electrons, whilst treating a significant proportion of the protein (more than 1000 atoms) with density functional theory. The computed electronic structure of the myoglobin complexes and the nature of the Fe-O2 bonding are validated against experimental spectroscopic observables. We elucidate and solve a long standing problem related to the quantum-mechanical description of the respiration process, namely that DFT calculations predict a strong imbalance between O2 and CO binding, favoring the latter to an unphysically large extent. We show that the explicit inclusion of many body-effects induced by the Hunds coupling mechanism results in the correct prediction of similar binding energies for oxy- and carbonmonoxymyoglobin.