What did Jesus mean when he was saying Why have you forsaken me? He was quoting from Psalm 22 and was referring to this whole Psalm--it would seem that it was actually a statement of faith and not doubt. It showed confidence in God in spite of the great suffering.
As Dr.Sri says in an article found here: In quoting the first line of Psalm 22 – ‘My God, my God, why have you forsaken me?’ – Jesus would be invoking the whole context of this psalm. Since the psalm expresses trust in God and ends on a clearly victorious note, ancient Jews would not interpret Christ’s words as a cry of despair.
22 uMy God, my God, why
have you forsaken me?
2 O my God, I cry by xday, but you do not answer,
3 Yet you are yholy,
5 To you they bcried and were rescued;
in you they ctrusted and were not put to shame.
6 But I am da worm and not a man,
7 All who see me gmock me;
they make mouths at me; they hwag their heads;
let him rescue him, for he kdelights in him!”
9 Yet you are he who ltook me from the womb;
and from mmy mother's womb you have been my God.
11 Be not nfar from me,
and there is onone to help.
13 they ropen wide their mouths at me,
14 I am spoured out like water,
and all my bones are tout of joint;
15 my strength is wdried up like a potsherd,
and my xtongue sticks to my jaws;
16 For ydogs encompass me;
a company of evildoers zencircles me;
they bstare and gloat over me;
18 cthey divide my garments among them,
19 But you, O Lord, ndo not be far off!
O you my help, dcome quickly to my aid!
my precious life from the power of ethe dog!
21 Save me from fthe mouth of the lion!
23 You who jfear the Lord, praise him!
All you offspring of Jacob, kglorify him,
the affliction of lthe afflicted,
and he has not mhidden his face from him,
but has heard, when he ncried to him.
25 From you comes my praise in the great ocongregation;
May your hearts tlive forever!
27 All uthe ends of the earth shall remember
and all vthe families of the nations
28 For wkingship belongs to the Lord,
29 All xthe prosperous of the earth eat and worship;
before him shall ybow all who go down to the dust,
even the one who could not zkeep himself alive.
it shall be told of the Lord to the coming ageneration;