There is no tzaddik on earth who does good and does not sin. Sometimes Hashem brings yissurim to spare a person suffering in the World to Come, or to cleanse the soul. Ramchal wrote that even tokhechot and yissurim were only preparations for good. One should strive to be glad in one’s lot, and trust Hashem chose the best situation.