The principal driving force for solution formation is that, inside the solution, there is greater randomness than inside either solvent or solute alone. The structure of the solute usually is thought of as being highly disrupted. There are many tradeoffs in this model. For example, solvent molecules may become much more regularly oriented (less randomly oriented) when contacting solute molecules than when contacting one another. This change in randomness is spoken of as the entropy of solution formation.
In some solutions, like salt in water, the solute interacts strongly with the solvent. The energy of these interactions is the enthalpy of the solution process. The entire process can be broken up into steps.
Solute -> Solute particles (Energy from solute interactions) (endothermic) Solvent -> Solvent particles (Energy from solvent interactions) (endothermic) Solute particles + Solvent particles -> Solution (Energy from solute-solvent interactions) (usually exothermic)
The last process is the energy source for the first 2 processes during the formation of most solutions. The process of dissolving of a solid that is endothermic may still be spontaneous because of the entropy increase that occurs when a solid disperses in a liquid.
Nearly everything dissolves at least a tiny bit in everything else because of the enormous, favorable entropy change connected to solution formation. So, even though glass is very insoluble, just a bit a glass always dissolves into the otherwise 'pure' water or solvent it might contain.