Myoglobin modulates the binding of diatomic molecules to its heme group via hydrogen-bonding and steric interactions with neighboring residues, and is an important benchmark for computational studies of biomolecules. We have performed calculations on the heme binding site and a significant proportion of the protein environment (more than 1000 atoms) using linear-scaling density functional theory and the DFT+U method to correct for self-interaction errors associated with localized 3d states. We confirm both the hydrogen-bonding nature of the discrimination effect (3.6 kcal/mol) and assumptions that the relative strain energy stored in the protein is low (less than 1 kcal/mol). Our calculations significantly widen the scope for tackling problems in drug design and enzymology, especially in cases where electron localization, allostery, or long-ranged polarization influence ligand binding and reaction.