There is an excellent article on endogenous retroviruses by Carl Zimmer. These are viruses that get stuck in the human genome. All viruses insert DNA into the cells' DNA so that that they hijack the cell's machinery to make more virus. Sometimes they find their way into an egg cell and do not kill the cell. In these cases the DNA is inherited by the offspring.
Scientists have discovered ways to recognize these retroviruses in the genome and found their a lot of them about 8% of the total human genome. Interesting they play an important role in evolution.
Once viruses get established in a genome, they can take any of a number of evolutionary paths. They may still be able to break out of their resident genome, become full-blown viruses, and invade another cell in the body. If they've lost the ability to become true viruses, their DNA can still get accidentally copied and inserted back into the genome. These copies may accidentally get swapped, producing drastic changes in their host's genome. And most remarkable, sometimes genes from viruses become useful to their hosts. It appears that virus genes have become vital for the development of primate placentas, and to carry out other essential tasks. While these genes retain distinctive sequences seen only in retroviruses, they show signs of having been preserved by natural selection, even as the viral genes that surround them have mutated into uselessness.