Atoms gain, lose, or share electrons to gain a full outer, valence shell. Since most atoms have an outer shell that isn't completely full, they will bond with other atoms or ions to gain a full valence shell.
(Side note: This is why noble gases do not bond; they already have a complete valence shell.)
Hope this helps!