This question is a good one that reflects how many of us feel at various times about prayer. We pray for something and it doesn’t happen and we wonder why. We are naturally led to one of three conclusions, either that God is powerless, that he doesn’t care or that prayer is pointless - all of which are contained in your question.
The first thing I’d like to examine is the principal purpose of prayer.
Prayer in the New Testament is always grounded on the will of God being done on earth (Matthew 6:10, 26:39). This reflects the attitude of prayer that we are coming before a God who has sovereign power and is in control of all things upon this earth - Colossians 1:17 declares that in Jesus ‘all things hold together’. We pray to a God who is able to answer our prayers but we come before him in humility because he is sovereign. We pray ‘your will be done’ because he alone is God. So Prayer is an exercise of humility where we recognise God as God and ourselves as in total dependence upon him.
God isn’t a genie enslaved to our desires, but rather a good God who genuinely seeks our good (more on this later) and hears our prayers but may not answer them or may answer them in an unexpected way. Consider as an example the frequency of Jesus’ prayers - he was constantly in prayer yet his prayer that God would spare him being crucified was not answered (Matthew 26:39)
Below I outline some of the key subjects of prayer in the New Testament:
Prayer for protection from evil or suffering (Luke 21:36, James 5:13-18)
Prayer that God would direct people to right decisions (Acts 1:24)
Prayer that God would spread his gospel (Romans 15:30-32)
Prayer that God would grow his Christian people (Ephesians 1:17-19, Colossians 1:9)
Prayer for whatever brings you anxiety (Philippians 4:6)
Prayer for good government (1 Timothy 2:1)
To be thankful (Colossians 4:2-3, 1 Thessalonians 5:17-18, 1 Timothy 4:4-5)
Notice that most of these prayers are centred on Godly rather than human concerns. Our prayers then submit us to God and his divine will. Prayer is relational and allows us to acknowledge God’s providence and to thank him for it whilst at the same time we are able to place our petitions before him which he lovingly deals with (even if that prayer isn’t answered). In prayer we acknowledge that his plans for us and the world (even death and suffering) are more profitable than our best laid plans.
How do we know this is right, or to paraphrase your question - Does God care either way?
Ultimately the answer to this is seen in the cross where Jesus in very nature God became human and died in order to pay the debt to God that we could not (Philippians 2:5-11). His death on the cross shows us that God does care about us and that death and suffering is not defeat for God’s eternal plan.
So then with respect to your last comments about ‘random outcomes’ and that the ‘good / prayerful are no better off than unbelievers’ - humanly speaking this is true. But God is sovereignly controlling this world and our apparent position in this world is no reflection of our eternal standing through Jesus.
If you want to look at the importance of prayer, some other passages include Acts 6:4; 10:4; Romans 12:12; Revelation 5:8; 8:3-4.
Answers are kindly provided by our friends at Christianity.net.au