Scientists approximate dinosaur lifespan by attempting to determine the metabolism of the animal, looking at its size and bone growth, and comparing with similar animals that are still around today. Based on these factors, a stegosaurus may have lived 75 to 100 years.
Unfortunately, dinosaur fossils themselves tell relatively little about the lifespan of the animal they belonged to. Scientists can only theorize about the metabolism of the stegosaurus, a factor which would greatly affect its lifespan. Also, the fact that it had a brain roughly the size of a walnut wouldn't have helped the animal protect itself by outsmarting predators. The stegosaurus was preyed on by other meat-eating dinosaurs, such as the allosaurus, so while an untouched stegosaurus might die of old age at roughly 100 years old, it's probably more likely that the average lifespan was much lower than that.