For any salt dissolving in water, its not compulsory that enthalpy change needs to be negative. Yes, if it is negative then its better dissolving for sure, But it doesn't mean the enthalpy change has to be compulsorily negative for salt to dissolve in water.
Enthalpy change when we dissolve Nacl in water is positive. This is because breaking of ionic bonds in the crystal lattice of Nacl requires more energy than that of provided by hydration of Nacl. Yes, hydration energy for Nacl is less than the energy required to break the Nacl apart. Hence the extra energy which can add up with the hydration energy to break the bonds of Nacl apart comes from the heat of the water. So the extra amount of energy which hydration could not provide comes from the heat of the water. Hence water looses heat, becomes slightly cold and also hydration energy (exothermic process) is less than the required energy to break the bonds, hence the net enthalpy change is positive.
So till now we learnt that for Nacl hydration enthalpy is not greater than enthalpy required to break the bonds and hence the extra energy required to satisfy the bond breaking comes form the heat of the water, and as hydration enthalpy is less than required energy to break the bond of Nacl, the net enthalpy change is positive, hence endothermic process.
Now the question arises how comes then Nacl dissolve in water?
As already said its not compulsory that enthalpy change needs to be negative for a salt to dissolve in water. Remember my friend, dissolving depends upon ΔG. ΔG is the most important factor which decides weather the reaction will happen or not. If ΔG is negative and ΔH is positive, salt will for sure dissolve because dissolving of salt (or any reaction) depends on ΔG. So if ΔG is negative for the dissolving of salt then salt would dissolve. Infact for Nacl ΔG is negative. Lets see how.
ΔG= ΔH −TΔS.
In dissolving Nacl in water ΔS is very much positive because is dissolving Nacl, Na and Cl gets apart, increasing the disorderedness in the system, hence ΔS is highly positive. So practically TΔS term is higher than ΔH term and hence we end up having ΔG negative.
Hence as ΔG is negative, Nacl dissolve. Remember dissolving of Nacl depends on ΔG. Negative ΔG makes Nacl dissolve in water.