(My answer has gotten so long and unwieldy that I have no idea if it's even coherent anymore. I hope it will be useful to you in parts, even if it doesn't hang together as a whole.)
You really have two questions here.
...if I ask for a good grade on my exam, God cannot force me to study, or choose my answers. How can God help me without breaking my free will?
- How can God make good things happen for me without forcing me to act in certain ways?
Furthermore, He already knows the future and exactly what grade I will get (which is a part of His perfect plan), so why should I pray for a certain grade?
- Why should we expect that our prayers will change anything? Isn't God just going to give us whatever He wants to give us anyway?
I will attempt to answer the second question first, then come back around to the first one.
Why should we expect that our prayers will change anything?
First, let's discuss how free will works in "ordinary" actions, and then we'll move on to prayer.
Free will in "ordinary" actions
Will and outcomes
Suppose I pick up a salt shaker and move it to the other side of the table. Nobody made me do it. It was my own free will. I can honestly say, "I chose to move the salt shaker."
On the other hand, suppose that I went to pick up the salt shaker and found that I couldn't, because some prankster had glued it to the table. Would that mean that the prankster had taken away my free will? Strictly speaking, the answer is no. I still made my free choice to try to move the salt shaker; it was only my goal that was frustrated. Free will does not include a guarantee of desired outcomes.
But even in this case, my free will had some effect on the world around me, even if it wasn't the effect I wanted. The salt shaker has new fingerprints on it; the glue holding it to the table is somewhat looser than it was before; my arm is in a different position, and the muscles in that arm are now more tired. My own thoughts, too, are different because of the choice I made. So my choice was far from meaningless.
Human will within God's will
God did not have to create a universe where my choices had any effect whatsoever, let alone the effects that I intended. But He did. God created and sustains a universe in which salt shakers can (in most cases) be moved by human muscles. In theory, He could at any moment alter the universe so that salt shakers can only be moved by His express command, and the thought of trying to move a salt shaker never even crosses our minds. But He chooses not to. He permits our free-will choices to have an actual effect on the world around us. To use a phrase I once heard (which was paraphrasing St. Thomas Aquinas), "God grants us the dignity of being causes"—that is, the "cause" in "cause-and-effect".
So even when I am doing something "by myself", I am only able to do it because God is cooperating with me. And yet this does not take away my free will. It is a partnership.
Analogy to prayer
Prayer is not that different from trying to move that salt shaker. When we pray, we are taking action in the hope of causing some particular effect. Compared to picking up a salt shaker, the connection between cause and effect is far more mysterious and hidden from us. But the basic logic is the same: we do something, and then, through God's cooperation, the thing we wanted might happen.
God didn't have to set things up this way. He could have created a universe where prayer has no effect whatsoever. But instead he gave us the gift of prayer, and encouraged us to use it. He grants us the dignity of being causes.
"But there's a difference," you might be saying. "Answering a prayer doesn't follow a general rule like the laws of physics. God is personally making a decision as to what will happen. It's his will, not mine."
Suppose you take a test, and afterwards, you petition your professor to give you partial credit on an answer you got half-right. The professor does. Does that mean your will didn't matter? It's true that the professor ultimately made the choice, but it wouldn't have happened if you hadn't chosen to petition him.
"That's still different," you might be saying. "My professor is a human being. Humans can change their mind. God doesn't change. So whatever his will already is, that's what will happen."
Part of God's will is that our choices should have effects. That includes choosing to pray.
Suppose your professor had a private rule that anyone who comes to him asking for partial credit, and who can explain their reasoning, gets that credit. So your petition didn't really change his mind; his mind was already set. This is analogous to how God can answer our prayers without Himself changing.
On God's foreknowledge
Furthermore, He already knows the future and exactly what grade I will get (which is a part of His perfect plan), so why should I pray for a certain grade?
You could just as easily ask, "He already knows exactly what grade I will get, so why should I study?" In both cases, as I hope I've already made clear, you are choosing to take an action with the aim of improving your grade.
You are basically arguing in favor of predestination: that the future is set in stone, and our own actions have no impact on it whatsoever. But this is wrongheaded. The future is a result of our actions. God is a witness to that future, because he is outside of time, but that does not mean he has taken away our free will and forced the future to come out that way.
To quote C. S. Lewis:
[God] does not "foresee" you doing things tomorrow; He simply sees you doing them: because, though tomorrow is not yet there for you, it is for Him. You never supposed that your actions at this moment were any less free because God knows what you are doing. Well, He knows your tomorrow's actions in just the same way—because He is already in tomorrow and can simply watch you. In a sense, He does not know your action till you have done it: but then the moment at which you have done it is already "Now" for Him.
—Mere Christianity by C. S. Lewis, Book IV, Chapter 3: "Time and Beyond Time"
I also dispute the idea that it is "God's perfect plan" that you should score, say, 83% on your exam, as opposed to 82% or 84%. God allowing something to happen is very different from God causing it to happen, or even being glad it happened. When we start to believe that every little thing and every little detail is "part of God's plan", it leads us down a weird rabbit hole to a twisted, trying-to-be-God's-robot form of Christianity in which we earnestly attempt to discern if the Almighty wants us to put ketchup or mustard on this particular hot dog. God wants us to be good and to draw near to him in love, not to fill out his checklist of Every Event That I Have Planned For This Specific Day In History (which he refuses to let us see).
How can God make good things happen for me without forcing me to act in certain ways?
...if I ask for a good grade on my exam, God cannot force me to study, or choose my answers. How can God help me without breaking my free will?
Your performance on the exam is certainly dependent on your own choices and efforts, and God is (most likely) not going to whisper the answers in your ear if you don't study. But your performance can never be entirely dependent on those efforts. You don't have perfect control over reality, or even your own body. There is more than enough room for God to work. In fact, you need God's help to succeed, in the same way that a fish needs water to swim.
However, that doesn't mean that you will notice Him helping.
In C. S. Lewis's The Screwtape Letters, the senior demon Screwtape explains things this way to his "nephew" Wormwood, who has been assigned to tempt a particular human:
Don't forget to use the "heads I win, tails you lose" argument. If the thing he prays for doesn't happen, then that is one more proof that petitionary prayers don't work; if it does happen, he will, of course, be able to see some of the physical causes which led up to it, and "therefore it would have happened anyway", and thus granted prayer becomes just as good a proof as a denied one that prayers are ineffective.
You, being a spirit, will find it difficult to understand how he gets into this confusion. But you must remember that he takes Time for an ultimate reality. [...] If you tried to explain to him that men's prayers today are one of the innumerable co-ordinates with which the Enemy [i.e. God] harmonizes the weather of tomorrow, he would reply that then the Enemy always knew men were going to make those prayers and, if so, they did not pray freely but were predestined to do so. And he would add that the weather on a given day can be traced back through its causes to the original creation of matter itself—so that the whole thing, both on the human and on the material side, is given "from the word go". What he ought to say, of course, is obvious to us; that the problem of adapting the particular weather to the particular prayers is merely the appearance, at two points in his temporal mode of perception, of the problem of adapting the whole spiritual universe to the whole corporeal universe; that creation in its entirety operates at every point of space and time, or rather that their kind of consciousness forces them to encounter the whole, self-consistent creative act as a series of successive events.
—The Screwtape Letters by C. S. Lewis, Letter XXVII
In other words, God crafts the universe, including all of time, partly in response to human prayers. From our limited perspective, the effect may come "before" the cause. From His perspective, it is perhaps like one of those modern sculptures where taut wires hold the other components in a particular arrangement, with our prayers being the wires.
Again, God's ability to witness our actions throughout time does not deprive us of free will, as Screwtape also discusses:
Why that creative act leaves room for their free will [i.e. why God chooses to do things the way he does] is the problem of problems, the secret behind the Enemy's nonsense about "Love". How it does so is no problem at all; for the Enemy does not foresee the humans making their free contributions in a future, but sees them doing so in His unbounded Now. And obviously to watch a man doing something is not to make him do it.
—The Screwtape Letters by C. S. Lewis, Letter XXVII
"But how do I know that God didn't just manipulate me into praying?" you might ask. "That would violate my free will."
What do you mean by "manipulate"? If you're saying that God presented you with a set of circumstances where you were 100% guaranteed to choose to pray...well, the whole idea of free will is that there is no such thing as a 100% guaranteed choice. If a man puts a gun to your head and says "Give me all your money", you still have the option of refusing, even if the consequences would be unpleasant.
Technically, the existence or non-existence of free will can never be proven in the way that we are accustomed to proving things today. We can't run any experiments; we can't turn back the clock and see if we can make a previous choice differently. Even if we had a time machine, we would know that we'd made that choice before, so we wouldn't be reproducing the original scenario.
But we all act like we have free will. We all live our lives as though our decisions are our own. Even the determinists. In other words, we take it on faith.
Aside from all that...
A word of warning. The point of a prayer of petition is not to get God to grant our wishes like a genie. We should petition God to give us what we need to live the way he wants us to live. And you could live a life pleasing to God without ever taking an exam, let alone passing one.
II. PRAYER OF PETITION
[...]
2631 The first movement of the prayer of petition is asking forgiveness, like the tax collector in the parable: "God, be merciful to me a sinner!"105 It is a prerequisite for righteous and pure prayer. A trusting humility brings us back into the light of communion between the Father and his Son Jesus Christ and with one another, so that "we receive from him whatever we ask."106 Asking forgiveness is the prerequisite for both the Eucharistic liturgy and personal prayer.
2632 Christian petition is centered on the desire and search for the Kingdom to come, in keeping with the teaching of Christ.107 There is a hierarchy in these petitions: we pray first for the Kingdom, then for what is necessary to welcome it and cooperate with its coming. This collaboration with the mission of Christ and the Holy Spirit, which is now that of the Church, is the object of the prayer of the apostolic community.108 It is the prayer of Paul, the apostle par excellence, which reveals to us how the divine solicitude for all the churches ought to inspire Christian prayer.109 By prayer every baptized person works for the coming of the Kingdom.
2633 When we share in God's saving love, we understand that every need can become the object of petition. Christ, who assumed all things in order to redeem all things, is glorified by what we ask the Father in his name.110 It is with this confidence that St. James and St. Paul exhort us to pray at all times.111
105 Lk 18:13.
106 1 Jn 3:22; cf. 1:7-2:2.
107 Cf. Mt 6:10, 33; Lk 11:2, 13.
108 Cf. Acts 6:6; 13:3.
109 Rom 10:1; Eph 1:16-23; Phil 1:9-11; Col 1:3-6; 4:3-4, 12.
110 Cf. Jn 14:13.
111 Cf. Jas 1:5-8; Eph 5:20; Phil 4:6-7; Col 3:16-17; 1 Thess 5:17-18.
—Catechism of the Catholic Church, Second Edition
Though, to give a word of warning to my word of warning, that doesn't mean you can't pray for success in your exams. Screwtape again:
On the seemingly pious ground that "praise and communion with God is the true prayer", humans can often be lured into direct disobedience to the Enemy who (in His usual flat, commonplace, uninteresting way) has definitely told them to pray for their daily bread and the recovery of their sick. You will, of course, conceal from him the fact that the prayer for daily bread, interpreted in a "spiritual sense", is really just as crudely petitionary as it is in any other sense.
—The Screwtape Letters by C. S. Lewis, Letter XXVII