Why does thymine replace uracil in DNA?

First, some clarification. As you already know, the difference between RNA and DNA is the existence of a hydroxyl (-OH) group on the 2' carbon of the ribose sugar in the backbone. The removal of 2' hydroxyl groups from DNA does not occur after the DNA has been synthesized, but rather the 2' hydroxyl groups are removed from the nucleotides before they are incorporated into the DNA. During nucleotide synthesis, a portion of the nucleotide monophosphates (NMP's) are dehydroxylated to 2'-deoxy-nucleotide monophosphates (dNMP's). This means that GMP, AMP, CMP, and UMP are converted into dGMP, dAMP, dCMP, and dUMP, respectively. However, before being incorporated into the chromosomes, another modification, using folic acid as a catalyst, methylates the uracil in dUMP to form a thymine making it dTMP. After further phosphorylation, dGTP, dATP, dCTP, and dTTP can be used as the building blocks to construct DNA.

The important thing to notice is that while uracil exists as both uridine (U) and deoxy-uridine (dU), thymine only exists as deoxy-thymidine (dT). So the question becomes: Why do cells go to the trouble of methylating uracil to thymine before it can be used in DNA?

The answer is: methylation protects the DNA. Beside using dT instead of dU, most organisms also use various enzymes to modify DNA after it has been synthesized. Two such enzymes, dam and dcm methylate adenines and cytosines, respectively, along the entire DNA strand. This methylation makes the DNA unrecognizable to many Nucleases (enzymes which break down DNA and RNA), so that it cannot be easily attacked by invaders, like viruses or certain bacteria. Obviously, methylating the nucleotides before they are incorporated ensures that the entire strand of DNA is protected. Thymine also protects the DNA in another way. If you look at the components of nucleic acids, phosphates, sugars, and bases, you see that they are all very hydrophilic (water soluble). Obviously, adding a hydrophobic (water insoluble) methyl group to part of the DNA is going to change the characteristics of the molecule. The major effect is that the methyl group will be repelled by the rest of the DNA, moving it to a fixed position in the major groove of the helix. This solves an important problem with uracil - though it prefers adenine, uracil can base-pair with almost any other base, including itself, depending on how it situates itself in the helix. By tacking it down to a single conformation, the methyl group restricts uracil (thymine) to pairing only with adenine. This greatly improves the efficiency of DNA replication, by reducing the rate of mismatches, and thus mutations.

To sum up: the replacement of thymine for uracil in DNA protects the DNA from attack and maintains the fidelity of DNA replication.