These shortened words are known as contractions. They're used in writing in order to reflect he patterns of speech.
In spoken English, we're always shortening or clipping words in order to express ourselves more efficiently. (This process of shortening goes on in all languages.) Over time, some of the most common and widely-used shortenings have become accepted into the written language as well, and these are usually spelled with an apostrophe:
They are -> they're
We will -> We'll
You had said -> You'd said
The number of contractions accepted in standard written English is pretty small and limited, covering basically just the forms of the verb to be, modal to have, and some of the modal verbs.
There are other contractions used in speech which are not commonly presented in writing. One example is the word because, which is often shortened to just its second syllable. This is sometimes written as 'cos or cuz, but this spelling is not accepted in the standard language.
There are also a handful of contractions which have written forms, but whose spoken forms have fallen out of use. The most notable member of this group is probably 'twas (it was), which is familiar from old poems and songs, but otherwise rarely occurs in modern speech.