Why does an antenna trace have this shape?
This is referred to as a meander antenna, which is a specific type of folded dipole.

Advantages:


Improve omnidirectionality
Smaller space requirements


Disadvantages:


Tuning becomes more critical
Losses are higher than a standard dipole


The Freescale App note, "Compact Integrated Antennas" gives a brief overview of several options, included the meander, for on-PCB antennas.  It doesn't give specific design parameters.

A 1982 dissertation, "Meander Antennas" provides some guidance on the mathematical models used to understand and design meander antennas, but goes rather deeper than most EEs will want to venture for simply designing an antenna.

The reality today is that most PCB antenna design of this type is usually done with the aid of an antenna design CAD package.  The antenna performance depends on not just the physical layout, but also the materials used, and the shape of those materials, for the PCB substrate, copper, and mask.  The software still has some limitations, and so extensive testing is done to validate and tweak the design once it's fabricated.  An example of free antenna analysis software is 4nec2 which can evaluate many types of antennas.

When designing a meander antenna, start with a trace the length of the ideal dipole, fold it into the desired shape and space, then perform numerical analysis to determine the radiation pattern and efficiency.  Some CAD software has wizards that can help you choose an optimal pattern for a given space, but I have not yet seen a book or guide that gives optimal pattern information that can be applied generally to meander antennas.