Hydrogen atom has only one elecron and thus of attain stable inert gas configuration of helium, it needs one more electron. Hence, to achieve stable inert has configuration of helium, it shares its single electron with electron of other hydrogen and thus form a stable diatomic molecule.