The ideal gas equation makes two main assumptions which break down when talking about real gasses:
1) the ideal gas equation assumes that gas molecules take up no space, and
2) the ideal gas equation assumes that there are no intermolecular attractions/repulsions between gas molecules.
Therefore a more ideal gas would have small molecules and have small intermolecular forces, while molecules of a more non-ideal gas would have a large volume and have significant intermolecular forces.
So, I agree with mike's answer. H2 has a small molecular volume and has very small intermolecular forces (especially since dispersion forces decrease with molecular size). CO, has a large molecular volume and its intermolecular forces are greater due to dipole-dipole interactions.