There is nothing we can do to absolutely guarantee a long life on this earth. The reason for this is that we are not ultimately sovereign over the length of our lives, God is.
Is there any way to guarantee ourselves a long life on earth?
James 4:13–15 says, "Come now, you who say, 'Today or tomorrow we will go into such and such a town and spend a year there and trade and make a profit'— yet you do not know what tomorrow will bring. What is your life? For you are a mist that appears for a little time and then vanishes. Instead you ought to say, 'If the Lord wills, we will live and do this or that.'"
However, God has given us some directions whereby we are more likely to live a long life. For instance, Paul reminds of the promise God made to the Israelites in Exodus 20:12, which seems to be generally applicable today. In Ephesians 6:1–3 he wrote, "Children, obey your parents in the Lord, for this is right. 'Honor your father and mother' (this is the first commandment with a promise), 'that it may go well with you and that you may live long in the land.'" While honoring our parents is not an absolute guarantee of long life, Scripture does associate it with long life. To honor one's parents is wise and God rewards such obedience.
Wisdom in general is also associated with a long life. Proverbs 3:13–16 says, "Blessed is the one who finds wisdom, and the one who gets understanding, for the gain from her is better than gain from silver and her profit better than gold. She is more precious than jewels, and nothing you desire can compare with her. Long life is in her right hand; in her left hand are riches and honor."
Wisdom is applied knowledge and the beginning of knowledge is to fear God (Proverbs 1:7). Those who fear God will seek to keep His commandments. This is the way of wisdom and wisdom carries long life in her right hand. If you would have long life, you must be wise. If you would be wise, you must know God's word. The book of Proverbs is a good place to start.
Proverbs 1:1–7 says, "The proverbs of Solomon, son of David, king of Israel: To know wisdom and instruction, to understand words of insight, to receive instruction in wise dealing, in righteousness, justice, and equity; to give prudence to the simple, knowledge and discretion to the youth— Let the wise hear and increase in learning, and the one who understands obtain guidance, to understand a proverb and a saying, the words of the wise and their riddles. The fear of the Lord is the beginning of knowledge; fools despise wisdom and instruction."
The book of Proverbs is filled with wise sayings which warn us to avoid such sins as violence, murder, stealing, anger, strife, lust, adultery, drunkenness, gluttony, sloth, lying, fraud, gossip, and many other evils. These sins are obvious culprits in the shortening of our lives. On the contrary, we are instructed to fear, trust, and obey God and to keep His commandments, which are generally associated with long life.
Proverbs 3:1–2 says, "My son, do not forget my teaching, but let your heart keep my commandments, for length of days and years of life and peace they will add to you." Similarly, Proverbs 9:10–11 says, "The fear of the Lord is the beginning of wisdom, and the knowledge of the Holy One is insight. For by me your days will be multiplied, and years will be added to your life."
Having said that, even a long earthly life of seventy or eighty years is relatively short in light of eternity (Psalm 90:10). Our lives are like a mist that appears for a short time and pass away (James 4:14). A flower that quickly fades (1 Peter 1:24).
Thankfully, God has provided not only wisdom for this life, but wisdom that leads to eternal life in the Person of His only Begotten Son, Jesus Christ, "in whom are hidden all the treasures of wisdom and knowledge" (Colossians 2:3). Those who believe in and receive Jesus Christ as Lord and Savior will inherit eternal life (John 3:16; 17:3; Romans 6:23; 1 John 5:13).
Hear Jesus' own words in the book of John: "The thief comes only to steal and kill and destroy. I came that they may have life and have it abundantly. I am the good shepherd. The good shepherd lays down his life for the sheep. … My sheep hear my voice, and I know them, and they follow me. I give them eternal life, and they will never perish, and no one will snatch them out of my hand" (John 10:10–11; 27–28).
If you would have long life you must know wisdom, but if you would have eternal life you must know He who is the embodiment of wisdom, Jesus Christ, our Lord and Savior.
Does life have meaning?
What does the command to honor my father and mother mean?
Life after death – Does it really exist?
Why are such long lives recorded in Genesis?
Can man live without God?
Truth about Humanity