Rabbi Akiva's death was foretold by Rabbi Eliezer ben Hyrkanus. In Avot de-Rebbi Natan 25 we find a description of Rabbi Elizer's last moments. He had been exiled to Caesarea after being excommunicated by Rabbi Yehoshua and the Sanhedrin. Yet he was the most brilliant mind of his generation. Only when he is on his death bed do the Rabbis come to visit him, and ask to learn Torah from him:
אחר כך אמר ר' אליעזר לחכמים: תמה אני על תלמידי הדור שמא יענשו מיתה לשמים.There is an almost identical version in the Bavli (Sanhedrin 68a):
אמרו לו: רבי מפני מה?
אמר להם: מפני שלא באו ושמשו אותי.
ואחר כך אמר לעקיבא בן יוסף: עקיבא, מפני מה לא באת לפני ושמשת אותי?
אמר לו: רבי, לא נפניתי.
אמר לו: תמה אני עליך אם תמות מיתת עצמך.
ויש אומרים: לא אמר לו כלום, אלא כיון שאמר רבי אליעזר לתלמידיו כך, מיד נמס דמו בקרבו.
אמר לו רבי עקיבא: רבי מיתתי במה?
אמר לו: עקיבא, שלך קשה מכולן.
נכנס רבי עקיבא וישב לפניו,
ואמר לו: רבי, מעתה שנה לי פתח.
ושנה לו שלוש מאות הלכות בבהרת.
'Why have ye come?' said he to them. 'To study the Torah', they replied; 'And why did ye not come before now', he asked? They answered, 'We had no time'. He then said, 'I will be surprised if these die a natural death'. R. Akiba asked him, 'And what will my death be?' and he answered, 'Yours will be more cruel than theirs'.I am not sure exactly how old Rabbi Akiva was when this exchange took place. Presumably he was still a student, rather than a teacher, in which case he lived for at least another 40 years after this. He knew that he would die a horrible death, and spent all his life preparing for it. And we know how he died, and how he explicitly said that he had been preparing for that moment his entire life Berachot 61b):
Our Rabbis taught: Once the wicked Government issued a decree forbidding the Jews to study and practise the Torah. Pappus b. Judah came and found R. Akiba publicly bringing gatherings together and occupying himself with the Torah. He said to him: Akiba, are you not afraid of the Government? He replied: I will explain to you with a parable. A fox was once walking alongside of a river, and he saw fishes going in swarms from one place to another. He said to them: From what are you fleeing? They replied: From the nets cast for us by men. He said to them: Would you like to come up on to the dry land so that you and I can live together in the way that my ancestors lived with your ancestors? They replied: Art thou the one that they call the cleverest of animals? Thou art not clever but foolish. If we are afraid in the element in which we live, how much more in the element in which we would die! So it is with us. If such is our condition when we sit and study the Torah, of which it is written, For that is thy life and the length of thy days, if we go and neglect it how much worse off we shall be! It is related that soon afterwards R. Akiba was arrested and thrown into prison, and Pappus b. Judah was also arrested and imprisoned next to him. He said to him: Pappus, who brought you here? He replied: Happy are you, R. Akiba, that you have been seized for busying yourself with the Torah! Alas for Pappus who has been seized for busying himself with idle things! When R. Akiba was taken out for execution, it was the hour for the recital of the Shema', and while they combed his flesh with iron combs, he was accepting upon himself the kingship of heaven. His disciples said to him: Our teacher, even to this point? He said to them: All my days I have been troubled by this verse, 'with all thy soul', [which I interpret,] 'even if He takes thy soul'. I said: When shall I have the opportunity of fulfilling this? Now that I have the opportunity shall I not fulfil it? He prolonged the word ehad until he expired while saying it. A bath kol went forth and proclaimed: Happy art thou, Akiba, that thy soul has departed with the word ehad! The ministering angels said before the Holy One, blessed be He: Such Torah, and such a reward? [He should have been] from them that die by Thy hand, O Lord. He replied to them: Their portion is in life. A bath kol went forth and proclaimed, Happy art thou, R. Akiba, that thou art destined for the life of the world to come.Moshe Rabbeinu could not understand Rabbi Akiva's death. But Rabbi Akiva himself not only understood it, but was waiting for it.
It is not unreasonable to assume that knowing he would be tortured to death by the Romans gave him the freedom to act without fear, since he no longer feared the only punishment that the Romans could give him. Perhaps this permitted him to be such a vocal supporter of Bar Kochba, even while the other Rabbis were more cautious in their support (or even opposed the uprising).