The formation of tiny balls (or knots, beads, etc) on a fabric is called "pilling."

Essentially, pilling happens when loose fibers in the fabric become entangled, forming knots and remaining attached to the yarns of the fabric until the fibers holding them in place are broken.

Pilling is impossible to completely avoid, but can be minimized by selecting a fabric with little or no "lint" such as a satin. Generally speaking, if you can peel a piece of masking tape from the fabric and come away with little to no lint, you shouldn't have to worry about pilling on that fabric. The more lint you get on the tape, the more readily the fabric will pill.  Needless to say, flannel has a lot of loose fibers and will always have some amount of pilling.  Satins have a very tight weave, and won't pill until it becomes very worn and the yarns begin to fray.

Other recommendations in avoiding pilling include: 

London Bridge Linens selects its fabrics very carefully, and packages sheets with explicit care instructions to avoid pilling as much as possible.  However, it falls to the sheet's users to follow those instructions and prevent or reduce pilling through these steps.  We cannot offer a warrantee against pilling.