Where the original company maintains the rights to market the drug exclusively. When that time expires, then generic drug companies can release their Walmart or Walgreen versions and usually sell them for much less.
From conversations I had with my OChem Prof, generic drugs aren't always as good as the brand name. Something about them not being held to the same development standards. The FDA mandates "bioequivalence" but the drugs released may not always be 100% the same. Idk someone with more knowledge can correct me or clarify further