Berachos (07a) He asked that He should show him the ways of G-d and it was granted to him. For it is said: Show me now Thy ways. Moses said before Him: Lord of the Universe, why is it that some righteous men prosper and others are in adversity, some wicked men prosper and others are in adversity? He replied to him: Moses, the righteous man who prospers is the righteous man the son of a righteous man; the righteous man who is in adversity is a righteous man the son of a wicked man. The wicked man who prospers is a wicked man son of a righteous man; the wicked man who is in adversity is a wicked man son of a wicked man.
Berachos (07a) The righteous man who prospers is a righteous man son of a righteous man; the righteous man who is in adversity is a righteous man son of a wicked man’. But this is not so! For, lo, one verse says: Visiting the iniquity of the fathers upon the children, and another verse says: Neither shall the children be put to death for the fathers. And a contradiction was pointed out between these two verses, and the answer was given that there is no contradiction. The one verse deals with children who continue in the same course as their fathers, and the other verse with children who do not continue in the course of their fathers! — You must therefore say that the Lord said thus to Moses: A righteous man who prospers is a perfectly righteous man; the righteous man who is in adversity is not a perfectly righteous man. The wicked man who prospers is not a perfectly wicked man; the wicked man who is in adversity is a perfectly wicked man. Now this is in opposition to the saying of R. Meir. For R. Meir said: only two requests were granted to him, and one was not granted to him. For it is said: And I will be gracious to whom I will be gracious, although he may not deserve it, And I will show mercy on whom I will show mercy, although he may not deserve it.
Kad HaKemach (Atonement 01) Suffering befalls a person to purge his sins, rendering him worthy of the World to Come. For this reason, G-d chastises the righteous for the few transgressions they possess—doing so during the fleeting time of this world and affecting the body—in order to grant them merit and reward them for their good deeds during the exalted time of the eternal World to Come, affecting the soul. This reflects the teaching of Rabbi Akiva "Beloved are sufferings..."
Kad HaKemach (Bitachon): An aspect of bitachon in G d is that even when a person has wealth, possessions, peace of mind and honor - he should not assume that this is reward for his good deeds. Even if he is a complete tzadik, it is better to even consider himself wicked and ascribe all the good entirely to the kindness of G d. On the other hand, if he suffers calamities or is attacked by bandits he should not view it as simply bad luck…. Such a response is the path of heresy. Rather he should ascribe the suffering to his many sins. In fact, if he insists that his suffering is merely bad luck, G d will give him additional “bad luck”…
Kad HaKemach (Parnossah 01) It is known that there are many reasons for preventing the righteous from receiving their sustenance. The great sage Rabbi Bachya ben Bekuda, , wrote about this in the Kuzari. Know that the reasons for which G-d will prevent the righteous from receiving his sustenance and food until he is troubled and tested may be for a sin that preceded him, and he has pledged to repay it, as in the case of "Behold, the righteous in the land will be rewarded," and it may be through a means of compensation in the World to Come, as he said, "To make you better in your latter end," and it may be to show his suffering and his good explanation in serving God so that people will learn from him, as in the case of Job, and it may be to appease the people of his generation and for God to test him with poverty and hardship and sickness to show his piety and service to God without them, as in the case of "Surely our sicknesses He Himself bore and our sorrows He Himself carried". And it may be because he is not jealous of God to take the judgment from the people of his generation, as you know from the case of Eli and his sons.
Moreh Nevuchim (03:51) We have already stated in the chapters which treat of Divine Providence, that Providence watches over every rational being according to the amount of intellect which that being possesses. Those who are perfect in their perception of God, whose mind is never separated from Him, enjoy always the influence of Providence. But those who, perfect in their knowledge of God, turn their mind sometimes away from God, enjoy the presence of Divine Providence only when they meditate on God; when their thoughts are engaged in other matters, divine Providence departs from them. The absence of Providence in this case is not like its absence in the case of those who do not reflect on God at all: it is in this case less intense, because when a person perfect in his knowledge of God is busy with worldly matters, he has not knowledge in actuality, but only knowledge in potentiality. This person is then like a trained scribe when he is not writing. Those who have no knowledge of God are like those who are in constant darkness and have never seen light.