One of the important discussions regarding imamate is the knowledge of the Imam. Two questions can be raised about this issue: 1- Is it necessary that the Imam should be the most knowledgeable person of his time? 2- What are the limitations of the knowledge of the Imam?
To answer the first question one thing is certain and that is: undoubtedly the Imam should be at least the most knowledgeable person of his time in religious matters. That is because being the most knowledgeable is a constituent of being the most virtuous, and it has been proved elsewhere that the Imam should be the most virtuous person of the Muslim community. When we say that the Imam should be the most virtuous person it means that he should also be the most knowledgeable person regarding religious matters.
Undoubtedly the Imam should be at least the most knowledgeable person of his time in religious matters. That is because being the most knowledgeable is a constituent of being the most virtuous, and it has been proved elsewhere that the Imam should be the most virtuous person of the Muslim community. When we say that the Imam should be the most virtuous person it means that he should also be the most knowledgeable person regarding religious matters.
Thus, the answer to the first question is that: The Imam of a community should be the most knowledgeable person among its members regarding religious rulings and all matters pertaining to religion.
But regarding the second question which is related to the limitations of the knowledge of the Imam we have to say that: The issue may be approached either rationally or religiously (i.e. based on the Quran and the traditions). In other words once it may be discussed by the help of reason that how much knowledgeable should be the one who is in charge of guiding the people and has been appointed as the Imam of the society? And another time it may be discussed by the help of the traditions to determine how the infallibles themselves have defined their knowledge and how wide they have described it.
Undoubtedly the reason rules that the Imam should necessarily be the most knowledgeable person in all fields pertaining to religion upon which the guidance of the people rely, lest he go astray and mislead the people. This comprehensiveness is not confined to religious sciences but extends to other fields which the guidance of the people relies on. For example he should be aware of sorcery and witchcraft to be able to nullify the efforts of sorcerers and the like who want the people go astray. The Imam should make their tricks known to people and prevent them from being deviated. Also he should know argumentation to stand against those who cast doubt on various religious matters and want to weaken the beliefs of people.
But should the Imam know all the professions and skills that exist? This is a matter of controversy. Some believe so maintaining that if the Imam does not know other professions and skills those who know them will feel more competent than Imam in those fields and thus will not be willing to follow the Imam in them. Some others believe that knowing them is not necessary for the Imam yet it is not impossible that he may know them. Sheik Mufid a great Shia scholar at the time of the minor occultation is of the second view. 
Undoubtedly the reason rules that the Imam should necessarily be the most knowledgeable person in all fields pertaining to religion upon which the guidance of the people rely, lest he go astray and mislead the people
According to some Shiite theologians knowing the unseen is not a constituent and necessary part of imamate and the reason does not oblige it, yet God may grant it to the Imam out of his mercy or because of expediency. Thus, if we come across traditions that confirm such knowledge for the Imams we have to accept them and shouldn't cast them aside. The skepticism and the questions that having such knowledge may arise have no grounds and are answerable because the Imam acquires such knowledge by the grace of God and His permission and if there is expediency for that.
Thus, based on reason there is no necessity that the Imam should know all things and there is no rational way to prove such knowledge for the Imam. Also knowing what other people have in mind is not necessary for Imam and knowing other languages is not an inseparable condition for imamate. In other words it does not mean that someone who does not have these types of knowledge could not be an Imam based on intellectual reasoning. But if we come across the traditions that confirm such knowledge for the Imam we accept them because they have been issued from a reliable source.
When it comes to traditions and we investigate the issue based on religious evidence we see that there are many hadiths confirming that Imam knows all professions, other languages and also he knows what others have in mind. There are also many traditions confirming that Imam knows the unseen. Therefore, because God has the prerogative to grant the knowledge of the unseen to whomever he wishes, and there are no rational obstacles to that, and because the traditions support it, we believe in it though as we said it is not necessary that the Imam should have such knowledge. 
There are even traditions that prove for the Imam the knowledge of "ما کان و ما یکون", that is, the knowledge of what has been in the past and what will be in the future. For example it has been narrated from Imam Sadiq (as) as saying:
" I know what is in heaven and what is on earth. I know what is in paradise and what is in hell. I know what was in the past and what will be in future".
Then he paused for a while and seeing that it was hard to perceive for those who were listening he added:
" I know these from the book of God because He said: «فِيهِ تِبْيَانُ كُلِّ شَيْءٍ» in it there is explanation for everything". 
 Sheikh Mufid, Awa'il al-Maqalat, p. 37.
 Research on Imamate(Investigating the views of the Imamis, the Mu'tazilites and the Ash'arites), p. 169.
 Kafi, Vol. 1, p. 261, « إِنِّي لَأَعْلَمُ مَا فِي السَّمَاوَاتِ وَ مَا فِي الْأَرْضِ وَ أَعْلَمُ مَا فِي الْجَنَّةِ وَ أَعْلَمُ مَا فِي النَّارِ وَ أَعْلَمُ مَا كَانَ وَ مَا يَكُونُ قَالَ ثُمَّ مَكَثَ هُنَيْئَةً فَرَأَى أَنَّ ذَلِكَ كَبُرَ عَلَى مَنْ سَمِعَهُ مِنْهُ فَقَالَ عَلِمْتُ ذَلِكَ مِنْ كِتَابِ اللَّهِ عَزَّ وَ جَلَّ إِنَّ اللَّهَ عَزَّ وَ جَلَّ يَقُولُ فِيهِ تِبْيَانُ كُلِّ شَيْءٍ».