It may just be that your water parameters were unsuitable for rams: they can be a bit sensitive and particularly don't like hard alkaline water.
If you want a fish that will live for 10 years+, why not try a catfish? If your tank is small, a bristlenose might do it- but don't buy a baby, infant mortality can be quite high, try to get a bigger individual. If you have a very big tank, a common plec might be worthwhile; and if you have a big coldwater, you can't beat goldfish
There are different reasons why fish don't live long in your tanks:
some species are naturally shortlived- annual killifish for instance, and some of the smaller poeciliids (heterandrias, I believe, but haven't tested); tetras and most other small fish can live for 4-6 years though if healthy
others may be inbred or prone to health problems- guppies and rams are often mentioned here (though of course one may still be lucky and find stronger specimens)
there is something wrong with your tank- such as ammonia, overcrowding etc
your water parameters do not suit that particular species (mollies are unlikely to be longlived in soft acid water, or rams in hard water)
you have been unlucky enough to get infection or parasites in your tank