Then when he says, "Have you suffered so great things in vain?" he amplifies their desertion by considering the evils they endured for Christ. For anyone who receives something without labor does not guard it as something precious; but that which is obtained by great effort, it is foolish to esteem lightly and not guard it. Now it was with labor and tribulation suffered at the hands of their fellow citizens that they had received the Holy Spirit. That is why he says, "Have you suffered so great things in vain?" As if to say: You ought not to despise so great a gift received with labor; "else y...ou have received it in vain," i.e., to no purpose, because you endured these things in order to attain to eternal life: "Tribulation worketh patience, and patience trial, and trial hope; and hope confoundeth not" (Rom 5:3). Hence, if you shut yourselves out from the door to eternal life by deserting the faith and seeking to be preserved by carnal observances, it is "in vain," i.e., uselessly, that "you have suffered." And I say, "If it be yet in vain." He says this because it was still in their power to repent, if they willed, as long as they were alive. This shows that certain deadened works are revived: "Their labors are without fruit, and their works unprofitable" (Wis 3:11); "I am afraid lest perhaps I have labored in vain among you" (4:11). If this is applied to evil men who do not repent, it can be said that they suffered without cause, i.e., a cause that can confer eternal life.
Source: Commentary on Galatians