I always heard that one who is a שוטה to a certain extent isn't obligated in Torah and Mitzvot. The first time I saw something similar inside is in Rambam Mishneh Torah (Yad Hachazaka) Hilchot Chametz U'Matzah Chapter 6 Halacha 3, where he paskens as follows:
אָכַל כְּזַיִת מַצָּה וְהוּא נִכְפֶּה בְּעֵת שְׁטוּתוֹ וְאַחַר כָּךְ נִתְרַפֵּא חַיָּב לֶאֱכל אַחַר שֶׁנִּתְרַפֵּא. לְפִי שֶׁאוֹתָהּ אֲכִילָה הָיְתָה בְּשָׁעָה שֶׁהָיָה פָּטוּר מִכָּל הַמִּצְוֹת.
[If] he had epilepsy and ate a kazayit of matzah at the time of his seizure, and was healed afterward, he is obligated to eat [it again] after he was healed, for the first eating, was at a time when he was exempt from all of the commandments.
So the question(s):
1. What are the illnesses or conditions that Halachicallly exempt someone from Torah and Mitzvot?
2. Do certain conditions have to be met (for example, regarding a person with epilepsy, it seems that according to the Rambam, that person is only exempt during a seizure)?
3. Have modern poskim differed than prior poskim because of yeridat hadorot?
4. Are there limitations to the exemption(s)?
Please provide sources for any answers.