I don't understand why a Christian would ask Yahweh for something while praying. For example, when a person gets sick, many people who know the patient or have heard of the situation will pray for the patient to get better and overcome the disease. However, if Yahweh is omniscient, then he would know everything about the situation and whether or not it would be best for the patient to recover regardless of whether people pray or not. In these sorts of situations, how are the Christians doing anything other than waste their time by praying for the person to get better?
Well,
we don't know if it is better or not for the person to be healed. All we know is that our loved one is ill and we want him to get better. And so we pray that he would get better. Doing so doesn't ignore what you've explained above: God may do the opposite in His divine perfectness and not heal our loved one, but that, it is understood, is always His divine prerogative.
When Jesus taught his disciples to pray he explained things to them this way:
Matthew 6:7-10
7 And when you pray, do not use vain repetitions as the heathen do. For they think that they will be heard for their many words.
8 Therefore do not be like them. For your Father knows the things you have need of before you ask Him.
9 In this manner, therefore, pray: Our Father in heaven, Hallowed be Your name.
10 Your kingdom come. Your will be done On earth as it is in heaven.
I find myself often simply praying "God, your will be done" for the very reason you point at in your question. God knows every situation far, far better than I do and understands exactly what best to do at all times.
Does this mean Christians should not ask their Heavenly Father for anything? No, the Bible doesn't teach that. In fact, Jesus continues in his demonstration to his disciples of correct prayer by requesting of God a number of things:
Matthew 6:11-13
11 Give us this day our daily bread.
12 And forgive us our debts, As we forgive our debtors.
13 And do not lead us into temptation, But deliver us from the evil one. For Yours is the kingdom and the power and the glory forever. Amen.
This is in accordance with the following principle of prayer Christ taught:
John 14:13-14
13 And whatever you ask in My name, that I will do, that the Father may be glorified in the Son.
14 If you ask anything in My name, I will do it.
And this principle is qualified by what the apostle John wrote in his first letter to first-century Christians:
1 John 5:14-15
14 Now this is the confidence that we have in Him, that if we ask anything according to His will, He hears us.
15 And if we know that He hears us, whatever we ask, we know that we have the petitions that we have asked of Him.
Jesus also taught the following concerning prayer:
Luke 11:9-13
9 "So I say to you, ask, and it will be given to you; seek, and you will find; knock, and it will be opened to you.
10 For everyone who asks receives, and he who seeks finds, and to him who knocks it will be opened.
11 If a son asks for bread from any father among you, will he give him a stone? Or if he asks for a fish, will he give him a serpent instead of a fish?
12 Or if he asks for an egg, will he offer him a scorpion?
13 If you then, being evil, know how to give good gifts to your children, how much more will your heavenly Father give the Holy Spirit to those who ask Him!"
Why do we ask God for anything when He already knows what is best? Because prayer is not for God's benefit but for
ours. It is in prayer that we acknowledge God's central and vital role in all things; in prayer we remind ourselves of His character, power, and provision; in prayer we confess our utter dependency upon Him; in prayer we commune with God as we must commune with anyone with whom we wish to have a relationship; in prayer faith in God is exercised and strengthened. Thus it is that prayer is so vital an element of each Christian's walk with God.
Selah.