An Exp. Share is a hold item used to distrubute experience to another Pokémon when equipped without the Pokémon needing to be used in battle. But, it does not get all the exp. it would get if it was in battle at one point.
Exp. Shares can be gained by defeating a boss Pokémon.