It depends. Sometimes it's simply more profitable to produce something else. Sometimes the market is too small to justify the bioequivalence studies. Sometimes the FDA mysteriously changes its mind on the safety of a drug the same day the patent expires [1].
[1] http://www.npr.org/sections/health-shots/2013/04/17/17760239...