We don't know that much about how planetary systems form, but the clues we have suggest an answer to this question. The massive outer planets DO have quite a lot of hydrogen in them, locked up in methane, ammonia and other hydrogenic compounds. The inner rocky planets have little of these elements present in a free state. When the Sun and solar system were first forming, the material probably did have the elements distributed in abundance in accord with cosmological ratios: 75% hydrogen, 24% helium and 1% everything else. But, these elements entered into chemical reactions within the proto-planetary disk in a so-called 'chemical condensation sequence' because the innermost regions of the disk were very hot ( 1000 - 2000 K) while the distant regions were very cold ( 20 - 100 K).
In the inner regions, where the planets Mercury, Venus, Earth and Mars are now found, helium of course is inert so it never got significantly locked-up in any compounds, however, some hydrogen did get locked up in methane, ammonia and ices. In the outer solar system, even more of the hydrogen got locked-up in methane and ammonia because of the colder temperatures.
In one model for forming the planets, all of the planets accreted material in their surroundings and formed very massive proto-planets. The terrestrial proto-planets were nearly as massive as Jupiter is now. In the cores of these massive proto-planets, the elements heavier than helium entered into chemical reactions to create the silicates and iron compounds so common to Mercury, Venus, Earth and Mars, but hydrogen helium and the trace gases of methane and ammonia remained in a dense gaseous atmosphere enveloping the rocky cores of the inner planets.
Soon after the Sun began to turn on its thermonuclear fusion in its core, there was a tremendous change in the surface of the Sun that caused a great 'T-Tauri' wind to blow through the solar system. We see such winds in very young stars similar in mass to the Sun, but only a few 10s of millions of years old. This wind would have easily stripped the inner planets bare of their massive, Jupiter-like, primordial hydrogen/helium atmospheres, but by the distance of Jupiter, its effects would have slackened considerably. The result is that the inner planets now only have rocky material, with no sign of the original hydrogen/helium atmosphere they originally accreted. The outer planets, such as Jupiter, still have most of the hydrogen and helium they accreted, and these are in fact similar to their cosmological and solar abundances for these elements.
This is one explanation why the Earth, today, doesn't have a chemical composition rich in hydrogen and helium.