Metals want to lose their electrons to form a full outer shell. The electrons in the outer shell become delocalised, which means they are free to move leaving a positive ion behind. The positive ions are then attracted to the delocalised electrons by the electrostatic force of attraction.