Atoms are not stable as their outer shells are not completely filled by the electrons. Some atoms like Na has tendency to loose electrons and achieve the stable noble gas configuration, whereas some atoms like Cl has tendency to gain electrons and achieve the stable noble gas configuration. Thus, molecules only get form after the combination of these atoms. When these atoms combine and form molecules then their energy is decreased as compared to the parent atoms.