When reading about plants I've heard that plants only produce for a few years, then die. Why can't they produce for as long as they're healthy?
Nothing lasts forever.The term perennial simply means a plant that will last for more than 2 years. That can mean 3 years that can mean 50 years or more. As the plants age they can lose their ability to produce the same quantity or quality of fruit.
Perennials don't live forever. They do eventually die or lose their ability to produce. For example asparagus is said to only produce for about 20 years. Lavender will survive for about 15 years.
In addition to their expected life span, other issues such as pests and disease can be a problem. These issues can build up over the course of many seasons. For various reasons it's suggested that strawberries be removed and new ones replanted every 4 years for example.
You might get a more meaningful answer if you indicate specific plants you're interested in.
It's called evolution. Different plants have different strategies to help replicate their genome across the planet. Annuals, or bi-annuals have found it best to flower in the first or second year. So, you'll see cabbages etc change their shape dramatically as they become tall and flowery so that they can disperse their seeds as far as possible. Once they have fulfilled their purpose, there's no biological need to persist and compete with their offspring, so they die.