While @Josh's answer is good and provides quite a lot of historical background for some of the specific nicknames, it doesn't completely address why, in general, names are truncated: the nicknames you've listed are diminutives:
A diminutive is a word which has been modified to convey a slighter degree of its root meaning, to convey the smallness of the object or quality named, or to convey a sense of intimacy or endearment...they are often employed as nicknames and pet names.
There's a link in that particular Wikipedia article for diminutives by language. Under that subsequent article, there are several names under the English subheading which are along the lines of the names you've listed:
The most common include shortening a longer name (e.g., "Pete" for Peter) or adding the diminutive suffix /i/ ("movie" for moving picture), variously spelled -y ("Sally" for Sarah), -ie ("Maggie" for Margaret), and -i ("Dani" for Danielle).
In short, such nicknames don't have to make sense based on the spelling of the original word (e.g. "Bill" for "William"); they're more commonly based on sound and length, as well as the "friendliness" of the alternative nickname form. In this case, "Bill" is much more informal, casual, and friendly than "William". In an exaggerated sense, think of it as the difference between your good friend "Bill" from the office and some nobleman named "William" from, say, England.