Jesus said, “Blessed are the pure in heart, for they shall see God” (Matt. 5:8). Hebrews 12:14 says, “Pursue peace with all people, and holiness, without which no one will see the Lord.” Holiness and purity are absolutely necessary for true prayer.
Those who take steps to see God and His holiness, so as to be holy like Him, to pray “Hallowed be Thy name,” to them God grants the pleasure of His friendship and of dwelling peacefully with Him. This I think is the essence of prayer—to be in His presence and to be in awe of His glory. Therefore, when we do what it takes to be holy we lay the groundwork for prayer.
Though friendship with God I think is so important for prayer, God desires that we go beyond friendship. He makes us holy so that in our friendship with Him we may also do His work and pray according to His will. Through holiness, as we dwell with Him in friendship, He makes us able to see things from His perspective and therefore to pray and serve Him according to His will.
Moreover, by holiness our prayers will be effective. James 5:16 says, “The effective, fervent prayer of a righteous man avails much. The word “righteous” here means to be godly. And in order to be godly we must set our heart to be holy—that is, to be as much like the sinless Jesus as we can be. If this is your goal, God will help you to accomplish it and will hear your prayers.