Despite the great abundance of Hydrogen and Helium in the Solar Nebula, Earth's atmosphere contains little of these two elements. Early in the solar-system history the strong solar wind cleared Earth of an atmosphere. The atmosphere we have today is a product of Earth degassing, primarily through volcanic activity, and geochemical recycling. Still, the hydrogen and helium contents are lower than one would expect. The reason is the constant escape of gas into space.
To escape from Earth, you must travel at least as fast as the escape velocity. Gas molecules are in constant motion - the velocity varies, but the hotter the gas, the faster the gas molecules move. Additionally, the lighter the gas molecules, the faster they move at a fixed temperature. The mean temperature of Earth's atmosphere allows the lightest elements to escape, but keeps in the heavier gasses such as oxygen and nitrogen.