The Bible was not teaching us to give thanks for evil. Evil does not come from God. But when the evil strikes we can still be thankful to God for the good he has done and how he kept you through your distress troubles. In everything give thanks. (1 thess. 5:18)