Why does wet hair keep its shape when it dries?
Hair, like fingernails and animal horn is made up mostly of a protein called Keratin. The strength and hardness of this polymer is caused by three types of chemical bonds: salt (ionic) bonds, hydrogen bonds and disulphide bonds. Water can significantly break the first two types (but not the disulphide ones).
Significantly wetting hair thus leads to making it more flexible and softer. But if wet and deformed hair dries it tends to retain the shape it was in while it was wet. The reformed hydrogen and salt bonds then leads to a 'permanent' deformation (until you wet it again).