Longevity is not something you need to be concerned about right away, but will be something to start thinking about as you continue to build your stable and establish yourself in the game.
A horse has a set amount of races they can run in their lifetime before their soundness starts declining. Racing puts a lot of wear and tear on a horse's body, so they cannot continue to perform forever. Most horses on FFH can race at least one year (about 10 races), but others may be able to have much longer careers lasting 3 or more years.
Generally speaking, unless your horse has a fair or poor Health gene, or peaks very late, there is no need to hold off on racing younger horses due to longevity. Most horses will run out of Peak and Prime before they run out of longevity, so it is usually in your best interest to race early and often, regardless of longevity and whether or not they are maxed. On the off chance you have a horse with fair or poor Health who needs to race a while longer than their natural longevity would allow for, feeding Eternity or a Mineral Block from Rusty will restore some longevity,
You can check a horse's Longevity by gaining the skill to see it on horse pages.
Horses may be retired once they have fewer than 10 races left on their longevity.
Once a horse is out of longevity, they will start running down soundness. While lower soundness does increase the likelihood of a horse being injured during a race, it is not a big deal to run on Soundness for a little while. Many horses can run on soundness for a year or longer, and there is absolutely nothing wrong with running on soundness for a few months to finish out a racing season. That said, most people do retire breeding stock before or shortly after they start running on soundness, since as stated running on soundness does increase the risk of injury.
Once your horse has run at least one race, you will be able to calculate how many races they have on their longevity. This calculation to figure out how many races your horse has in total is:
Current starts divided by the percentage of longevity they've already lost (written as a decimal)
The number you get from the above will be how many lifetime races your horse has. If you subtract their current starts from that number, you will know how many races they have left on their current longevity. If you feed Eternity or a Mineral Block, or transition to Marathon or SC, you will have to do these calculations again to discover their new numbers.