A shank is a device for providing a small amount of space in between a garment and a button.  Shanks are necessary to provide space for fabric to sit in between the button and the garment when the garment is buttoned.  Shanks also allow a garment to hang and drape nicely.

Types of shanks
There are two types of shanks:

Button shank
Shank buttons have a hollow protrusion on the back through which thread is sewn to attach the button. Button shanks may be a separate piece added to the back of a button, or be carved or moulded directly onto the back of the button, in which case the button is referred to by collectors as having a 'self-shank'. This is a common construction for older shell and glass buttons, for example. 
Buttons with shanks have no holes in the button blank (the main part of the button) itself because they are not needed for sewing.  Buttons with shanks are more expensive to produce than shankless buttons.

Thread shank

A thread shank is made of thread and is intended to be used with a shankless button (a button with typically two or four holes). It is created while a button is stitched onto a garment.

Creating a thread shank
A thread shank is created by loosely stitching a shankless button onto fabric.  This is usually done by keeping a toothpick or other small object in between the button and fabric while the button is stitched on.  Once the button has been sewn through a few times, the toothpick is removed and the needle is moved down through one of the buttonholes, placing the needle and its thread in between the button and fabric.  The sewer takes care to not tighten the thread too much.  While holding the button away from the garment, the thread is then firmly wrapped around the button (in between the button and fabric) a few times to form a sturdy wrapper for the other threads.  The needle is then pushed through the fabric to the underside of the garment, where it can then be securely fastened off.  A thread shank's length depends on the thickness of the fabric that will be buttoned.  The ideal thread shank is long enough to button the fabric and still have the garment draping nicely, but short enough that the button does not flop around when buttoned.

Specialty shanks
Regular thread is used on lightweight garments such as shirts which are subject to little stress, but a specialty thread called buttonhole twist is used on items that experience more wear and tear, such as coats and pants. If a sewer uses regular thread, they usually use a double thread to strengthen the quality of the stitching.
Long coats that are good-quality or better often have a special shank at the bottom button.  Because the bottom button of a coat is subject to a lot of stress, shanks are typically longer than usual and are sometimes made with elastic-thread.  In addition to the special shank, an additional (shankless) button with no thread shank is often used on the underside of the fabric when sewing the button on.  As a result, the stress to the button, shank, and thread pulls on this second button instead of the fabric.  This prevents the thread from damaging and ripping the fabric, and is one of two ways to prevent "popping a button" (the other method is to use good strong thread such as buttonhole twist).
In addition to the typical shank and shankless buttons, covered buttons are shank buttons that have fabric completely covering the back.  They are stitched on like regular shank buttons, but the sewer has to "feel" for the shank while they are sewing the button on.  Covered buttons are handmade (to some degree), expensive, and are used in high-end and specialty garments.

See also
Button
Sewing
Yarn

Citations

References
Singer Clothing Care & Repair by The Editors of Cy DeCosse Incorporated 
Threads magazine Issue 117 March 2005 pp.58

Textile closures
Buttons