There's really no law that states that carpet has to be replaced after a certain period of time.
But a carpet should be replaced in a rental home or any other home after 10 years time.
10 years is the recommended lifespan of carpet and at or after 10 years the carpet should be replaced.