He did not know that ghusl from janaabah is obligatory; should he repeat the prayers?
Question

I did not know that it is obligatory to do ghusl from janaabah (full ablution following sexual activity) in order to pray. Do I have to repeat the prayers?.
Praise be to Allah.Every Muslim, male or female, has to learn the rulings of Islam, especially those that have to do with the duties that Allah has enjoined upon him and that he is able to do. Whoever has wealth has to learn the rulings on zakaah; whoever works in business has to learn the rulings on buying and selling. And everyone has to learn the correct beliefs and what is required of every accountable person, the rulings on purification and prayer. Allah has made it easy for us to seek knowledge in various ways, so many people have no excuse for saying that they did not know, except negligence. 
With regard to this particular matter, which is not knowing that it is obligatory to do ghusl from janaabah, and that you offered many prayers whilst in this state, the scholars are of the view that this is regarded as something that may be excused, so you do not have to make up the prayers. But you have to do ghusl and repeat the prayer at the time of which you hear of the ruling. They quoted several reports as evidence for that: 
1 – It was narrated from Abu Hurayrah that the Messenger of Allah (peace and blessings of Allah be upon him) entered the mosque and a man entered and prayed and greeted the Prophet (peace and blessings of Allah be upon him) with salaam and he returned the greeting. Then he said: “Go back and pray, for you have not prayed.” So he went back and prayed as he had prayed the first time. Then he came and greeted the Prophet (peace and blessings of Allah be upon him) with salaam and he said: “Go back and pray for you have not prayed.” This happened three times, then he said: “By the One Who sent you with the truth, I cannot do any better; teach me.” He said: “When you stand to pray, say takbeer (“Allahu akbar”), then recite whatever you can of Qur’aan, then bow until you are at ease in bowing, then stand up until you are standing straight. Then prostrate until you are at ease in prostration, then sit up until you are at ease in sitting, and do that throughout the whole prayer.” Narrated by al-Bukhari, 724; Muslim, 367. The Prophet (peace and blessings of Allah be upon him) did not tell him to make up his past prayers, rather he told him to make up the current prayer only. 
2 – It was narrated that ‘Abd al-Rahmaan ibn Abza said: A man came to ‘Umar ibn al-Khattaab and said: I have become junub but I cannot find any water. ‘Ammaar ibn Yaasir said to ‘Umar ibn al-Khattaab: “Do you not remember when we were on a journey, you and I (and became junub)? You did not pray, but I rolled in the dust and prayed. I mentioned that to the Prophet (peace and blessings of Allah be upon him) and the Prophet (peace and blessings of Allah be upon him) said: ‘It would have been sufficient for you to do this,’ and the Prophet (peace and blessings of Allah be upon him) struck his palms on the ground and blew onto them, then he wiped them over his face and hands.”
Narrated by al-Bukhari, 331; Muslim, 368. 
‘Umar ibn al-Khattaab (may Allah be pleased with him) did not pray because he did not know that tayammum is obligatory for the one who cannot find water. ‘Ammaar ibn Yaasir (may Allah be pleased with him) did tayammum in a different way because he did not know how to do tayammum correctly. But the Prophet (peace and blessings of Allah be upon him) did not tell them to make up the prayers that they had missed. 
Shaykh al-Islam Ibn Taymiyah (may Allah be pleased with him) said: 
Based on this, if a person did not purify himself as prescribed in sharee’ah because the text had not reached him, such as if he ate camel meat and did not do wudu, then the text reached him and he came to know that it is obligatory to do wudu after eating camel meat, or if he prayed in a camel pen then the text reached him (which says that it is not allowed to pray in camel pens), does he have to repeat the past prayers? There are two opinions, both of which were narrated from Ahmad. 
A similar case is if a man touches his penis and prays, then he finds out that the one who touches his penis has to do wudu. 
The correct view in all these cases is that he does not have to repeat the prayers, because Allah has forgiven things done by mistake or out of forgetfulness, and because He says (interpretation of the meaning): 
“And We never punish until We have sent a Messenger (to give warning)” [al-Isra’ 17:15]
If a person has not heard of the command of the Messenger of Allah (peace and blessings of Allah be upon him) concerning a particular matter, then the obligation is not confirmed in his case. Hence when ‘Umar and ‘Ammaar became junub and ‘Umar did not pray and ‘Ammaar prayed after rolling in the dust, the Prophet (peace and blessings of Allah be upon him) did not tell either of them to repeat the prayer. Similarly he did not tell Abu Dharr to repeat the prayers when he was junub and did not pray for several days. And he did not tell those of his companions who had eaten until they could distinguish the white thread from the black thread to make up their fasts, and he did not tell those who had prayed facing Bayt al-Maqdis (Jerusalem) before news of the abrogation reached them to make up those prayers. 
A similar case is that of the woman who was suffering from istihaadah (non-menstrual vaginal bleeding) and had not prayed for some time because she thought that she did not have to pray. There are two views as to whether such a woman has to make up the prayers she missed. One view is that she does not have to make up the prayers – as was narrated from Maalik and others – because when the woman who was suffering from istihaadah said to the Prophet (peace and blessings of Allah be upon him): “I have been bleeding heavily for some time and it prevents me from praying and fasting,” he told her what she should do in the future, and he did not tell her to make up the prayers of the past. 
It seems to me, based on mutawaatir reports, that with regard to women and men living in the desert and elsewhere who have reached the age of puberty and do not know that prayer is obligatory for them, and even if it is said to such a woman, “You have to pray” and she says, “Not until I grow up and become an old woman, thinking that the command to pray is only addressed to old women, and even the followers of some shaykhs (among the Sufis) groups do not know that prayer is obligatory for them, according to the correct view, they do not make to make up past prayers regardless of whether it is said that they were kaafirs or they were excused for their ignorance. 
Majmoo’ al-Fatawa, 21/101, 102. 
See also the answer to question no. 21806 . 
It may be noted here that if the questioner was in a place where the means of acquiring knowledge were available but he was careless and did not try to find out, then he has to make up the prayers that he offered without ghusl from janaabah, so long as he is not very old. If he is very old, he does not have to make them up because of the hardship that that would cause, because Allah says (interpretation of the meaning):
“and [Allah] has not laid upon you in religion any hardship” [al-Hajj 22:78]
And Allah knows best.