Nice question. I must say it took me many hours to get satisfactory answer.
Hairs are made of keratin molecules, which contain cysteine. Cysteine has thiol (-SH) group, by which it can form disulfide (-S-S-) bond with another cysteine of another keratin, causing bending of hair. See this image from here:
Curling of hair can be justified on both microscopic and macroscopic level.
- Microscopic level: See this post from here:
Curly hair has to do with the chemical bonds in the protein that makes up hair - $\alpha$-keratin. Keratins, particularly $\alpha$-keratin, have long sequences of amino acids (often more than 300) which forms a helical structure.
Pairs of these helical structures then coil about each other in a left-hand coiled-coil structure. These are then attracted to another coiled coil so two keratin helices will stick together. These four-chain structures then associates with another four-chain structure to form the hair filament. One of the amino acids which make up these chains, is cysteine which has a sulpher group which is able to make connections with other sulpher groups on other coiled coils.
The more interactions a filament has with another filament, the more tightly coiled the coiled-coil becomes. Hence, curly hair has more interactions than straight hair. The process of `perming' hair introduces more accessibility of the sulpher on the amino acid, cysteine, to make these connections. Finger and toe nails have many many bonds between filaments and are thus, very hard.
For example, see how hairs are curled artificially via perming.
This change in location of bonds is what causes curling of the hair (look again at the first diagram and notice the orientation of disulfide bridges). Those vertical strands now get curled due to change in these bonds. Here, the required mechanical tension for bending is provided artificially.
- Macroscopic level: Shape of hairs is also determined by its macroscopic structure. Look at this article:
All hair, whether curly or straight, has two major components: the shaft and the follicle. The shafts are the visible, flowing strands that we see on our heads. The follicle is the part of our hair that resides within the skin, or dermis, of our scalp. Each of these structures plays a role in determining our overall hair shape.
Let’s start at the root of the issue (pun 100 percent intended): the follicle. It turns out that the shape of our follicles is a major determinant of our hair texture. If you were to look at the follicle of straight hair, you would find it is perfectly round. The follicle of curly hair adopts an oval shape. The flatter the oval is, the curlier the hair will be.
Another contributing factor to a hair’s curl is the way the follicle tunnels into the scalp. Follicles of straight hair tunnel vertically down from the skin’s surface into the dermis. If the follicle angles into the dermis then the hair will curve as it grows causing it curl. Although, this curving of the follicle can lead to gorgeous curls it causes one major drawback that all curly-haired persons can attest to, dryness. Within the dermis, special glands line the follicle to secrete oil, called sebum, to lubricate the hair. Unfortunately, when follicles curve sebum isn’t able to travel the length of the hair as well leading to dryness of hair that doesn’t get lubricated.
Although how shape of follicle determines structure of hair strand is probably not known, the major contributing factor likely is how hair emerges from the scalp. When it emerges in a bent shape, it faces a lot of tension from the scalp, which causes it to bend in the shape of the follicle to form curls. Since straight-emerging strands don't face such forces, they do not lead to curled hairs.
In this way, hair curls are a consequence of large number of disulfide bridges between keratin molecules and how the hair emerges from the scalp.