Why do good people suffer?

Why is that good people seem to suffer so much? Or that anything holy or good always seems to have so much opposition? We learn in Tanach the story of Ruth and Boaz: everyone thought Boaz made an error to marry Ruth and that is why he died the night after their wedding. However Hashem had other plans: He already planted the seed of Moshiach and King David descended from Ruth.  David himself looked to be possibly an illegitimate child and yet with time it was revealed that he was pure and holy and in fact became the King of Israel.
But why does so much holiness seem to come with so many problems?
Or why is it when there is a lot of kedusha and goodness there seem to be so many obstacles and challenges?
Many marriages that are truly bashert are beset by lots of opposition and difficulties. Why? 
David Hamelech was meant to marry Batsheva but the circumstances of their marriage was garbed in negativity and challenges.  Yehuda and Tamar: their marriage came about through complicated ways. Why did it have to be that way?
Many very holy pure people are suddenly challenged with difficulties and suffering. Why?
One thing we learn from physics: whenever there is a positive electrical current you need a negative current to make it function. If there is only positive energy it wont work. No light will be produced.
So in order to reveal light hidden within everything, we need both positive and negative poles. Anything positive automatically will draw some negativity but that is the way light is produced. And from that light people grow and attain higher levels and bring about great things . Yehuda and Tamar were bringing down the light of Moshiach. Boaz and Ruth were adding to that. David Hamelech was also bringing about the continuity leading to Moshiach. But all of that required challenges and negativity in order to bring out such a positive light.