Why AZT is selective towards HIV and doesn't impair human DNA replication?
Retroviruses depend on being able to convert their RNA genome into a DNA copy, and have a reverse transcriptase enzyme to do that. This unique activity is not found in human cells, allowing for potential antiviral therapy if a drug can be used to inhibit the reverse transcriptase while not affecting the human enzymes. 

AZT is one such drug, by mimicking the nucleotide thymidine, it can it can act as a substrate for nucleotide kinases and become 5' phosphorylated. AZT is phosphorylated by host cell enzymes, specifically thymidine kinase, this means that the levels of AZT phosphates are similar between HIV infected and non-infected cells. Once the 5' triphosphate is formed, the drug is a substrate for the viral reverse transcriptase. If an AZT is incorporated into the DNA backbone, it terminates the DNA because the 3' OH is not available for further polymerization.

However, at high enough doses AZT can be toxic to healthy cells. One mechanism for toxicity is the depletion of thymidine, because AZT competes with thymidine for the kinase enzymes, but is phosphorylated at a slower rate. At high doses, >1mM, AZT can act as a substrate for human DNA polymerases. Thankfully, AZT is about 100 fold more selective for HIV reverse transcriptase than human DNA polymerase.

The mitochondrial DNA polymerase seems to be a little more sensitive to AZT than other human DNA polymerases. This can lead to toxicity in the heart, skeletal muscles, hepatocytes, or other cells that use a lot of mitochondria. This toxicity is generally reversible if doses are reduced.

For more information, read about other nucleotide analogs, such as acyclovir, ganciclovir, and others which work through similar mechanisms.