In Generation II, Shininess is
determined by the IVs of a Pokémon. If
a Pokémon's Speed, Defense, and
Special IVs are 10, and its Attack IV
is 2, 3, 6, 7, 10, 11, 14 or 15, it
will be Shiny. This determination
allowed for compatibility with
Generation I, as if a Shiny Pokémon is
traded back, then traded forward, it
would retain its Shininess. Despite
the bonus of backward compatibility
allowing for a Shiny Pokémon to learn
Generation I TMs, provided it was a
Generation I Pokémon, Shiny Pokémon
are only slightly above average in
terms of IVs. Due to the probability
of the IVs lining up in any of these
manners to produce a Shiny Pokémon,
the chance of obtaining one in
Generation II is approximately 1/8192.
However, if one breeds a Shiny Pokémon
properly, the offspring may have as
high as a 1/64 chance of being Shiny,
depending on the species of Pokémon.
~Bulbapedia
This only applies to Generation II. In Generations II, IV, and V, the game determines shininess of a Pokémon using a calculation based on the Trainer ID number and secret ID number of the player ecountering it and the personality value of the Pokémon. Click here to learn about personality values.