At a high level, the battery is damaged just a little bit each time it's charged. The amount of damage caused during charging is based on the temperature and how full the battery is. This means the longevity of a lithium ion battery is basically a function of how many times they are charged, the temperature, and if you charge it to 100% or only to 70%.
In the real world, with the Model S, people are reporting under a 20% degradation after 100k miles. It should last somewhere between 300k-500k before it's half dead.
As I understand it, as the battery capacity decreased, there should be a plan would be to install a new fresh battery pack, with the old one reused in a role for stationary storage, before finally being recycled.