Heredity is the passage of genetic information from one generation to another. For offspring to inherit traitsthere must be a reliable mechanism for transferring genetic information from one generation to the next.
On a biological level, the main difference is that bacteria and free-living cells can live inside or outside a body, while viruses are a non-living collection of molocules that need a host to survive.