Why do ions form?

The simple explanation is that the outside shells of elements have either too many or not enough electrons. Those elements tnd to lose or gain electrons to complete their outside shells. The become ions when they do so.