Why is sodium chloride edible whereas both sodium and chlorine are highly reactive?
Sodium chloride is edible. But elemental sodium and chlorine are highly reactive and poisonous. What is the difference?


Solid sodium chloride is an ionic compound. This means it consists of positively charged sodium ions ($\ce{Na+}$) and negatively charged chloride ions ($\ce{Cl-}$) arranged in a cubic lattice.



On the other hand, sodium metal and chlorine gas are elements. $\ce{Na}$ has an electron configuration of $\mathrm{[Ne]~3s^1}$ and so it really wants to lose that single electron to form a full outer shell as a $\ce{Na+}$ ion. This makes it highly reactive towards species which can easily accept an electron such as $\ce{Cl2}$, $\ce{H2O}$ etc. $\ce{Na+}$ has a full outer shell, being isoelectronic with neon, and so it is quite happy to stay as an ion and not react. Chlorine, with an electron configuration of $\mathrm{[Ne]~3s^2~3p^5}$, really wants to gain a single electron to get a full outer shell, isoelectronic with argon, as the $\ce{Cl-}$ ion. This makes it highly reactive towards species which can easily donate an electron, such as $\ce{Na}$.


  is there any difference in eating sodium chloride in powder form and after dissolving in water?


Not really. Sodium chloride dissolved in water consists of hydrated $\ce{Na+}$ and $\ce{Cl-}$ ions. If you eat solid sodium chloride then it rapidly dissolves in the water in your body, so the effect is the same. Interestingly though, solid salt tastes quite nice, but salty water tends to taste horrible.