We are informed at the beginning of the Quran in Sura 2 that righteousness is a necessary quality for redemption:
[2:2] This scripture is infallible; a beacon for the righteous;
[2:5] These are guided by their Lord; these are the winners.
[2:112] Indeed, those who submit themselves absolutely to GOD alone, while leading a righteous life, will receive their recompense from their Lord; they have nothing to fear, nor will they grieve.
We know that righteousness is more important than what sect or tribe a person is from, and it is the most important garment:
[49:13] O people, we created you from the same male and female, and rendered you distinct peoples and tribes, that you may recognize one another. The best among you in the sight of GOD is the most righteous. GOD is Omniscient, Cognizant.
[2:62] Surely, those who believe, those who are Jewish, the Christians, and the converts; anyone who (1) believes in GOD, and (2) believes in the Last Day, and (3) leads a righteous life, will receive their recompense from their Lord. They have nothing to fear, nor will they grieve.
[7:26] O children of Adam, we have provided you with garments to cover your bodies, as well as for luxury. But the best garment is the garment of righteousness. These are some of GOD’s signs, that they may take heed.
Our accountable actions can be either righteous or evil:
[41:46] Whoever works righteousness does so for his own good, and whoever works evil does so to his own detriment. Your Lord is never unjust towards the people.
[11:114] You shall observe the Contact Prayers (Salat) at both ends of the day, and during the night. The righteous works wipe out the evil works. This is a reminder for those who would take heed.
God provides a general definition of righteousness in the Quran, which we can use as a measuring stick for ourselves:
[2:177] Righteousness is not turning your faces towards the east or the west. Righteous are those who believe in GOD, the Last Day, the angels, the scripture, and the prophets; and they give the money, cheerfully, to the relatives, the orphans, the needy, the traveling alien, the beggars, and to free the slaves; and they observe the Contact Prayers (Salat) and give the obligatory charity (Zakat); and they keep their word whenever they make a promise; and they steadfastly persevere in the face of persecution, hardship, and war. These are the truthful; these are the righteous.
[2:2-5] This scripture is infallible; a beacon for the righteous; who believe in the unseen, observe the Contact Prayers (Salat), and from our provisions to them, they give to charity. And they believe in what was revealed to you, and in what was revealed before you, and with regard to the Hereafter, they are absolutely certain. These are guided by their Lord; these are the winners.
However, we cannot attain the required righteousness on our own volition:
[35:8] Note the one whose evil work is adorned in his eyes, until he thinks that it is righteous. GOD thus sends astray whoever wills (to go astray), and He guides whoever wills (to be guided). Therefore, do not grieve over them.
GOD is fully aware of everything they do.
[103:1-3] By the afternoon. The human being is utterly lost. Except those who believe and lead a righteous life, and exhort one another to uphold the truth, and exhort one another to be steadfast.
God informs us that we must pray to him to direct us to do the righteous works that please him. It is important to ask God for help in this matter:
[27:19] …“My Lord, direct me to be appreciative of the blessings You have bestowed upon me and my parents, and to do the righteous works that please You. Admit me by Your mercy into the company of Your righteous servants.”
We are instructed to pray in the same manner:
[46:15] We enjoined the human being to honor his parents. His mother bore him arduously, gave birth to him arduously, and took intimate care of him for thirty months. When he reaches maturity, and reaches the age of forty, he should say, “My Lord, direct me to appreciate the blessings You have bestowed upon me and upon my parents, and to do the righteous works that please You. Let my children be righteous as well. I have repented to You; I am a submitter.”
A sincere Submitter to God alone will receive the guidance from God:
[49:17] They act as if they are doing you a favor by embracing Submission! Say, “You are not doing me any favors by embracing Submission. GOD is the One who is doing you a great favor by guiding you to the faith, if you are sincere.”
We see that we can attain righteousness through our sincerity in worshipping God alone and through His guidance and direction, which we have to ask for.