What does
"It's good for you to pass the exam"
mean?
If the situation is that "you" has already passed the exam, could the sentence mean that "It's good for you that you passed the exam"?
I think so at least according to this situation.
The phrase "it's good for you" means that a thing is beneficial to your overall state. For example: "Eat your broccoli: it is good for you."
So, this sentence means that you will be better off if you pass the exam. It might be encouragement to study for someone who thinks the exam does not matter for some reason.
Or, if they already have passed the exam, it would be a statement that the exam has some sort of value. Perhaps that grade will help in the future applying for a job, for example. In this case usually past tense would be used, but it could also be said in a general way (again, like "It's good for you to eat your veggies" even after you've just eaten them).
It would not normally be used as congratulations (except possibly in a case where the person you are speaking to needs encouragement about the value of the exam more than they need the actual celebration of a good result).
As written, the sentence expresses an opinion about a future event. To rephrase:
If you pass the exam, it will be good.
If you want to express the same opinion about a past event, using the same grammar, there are a couple of options:
It's good for you to have passed the exam.
It's good that you passed the exam.
If you want to express a general opinion, rather than refer to any specific instance, use the plural:
It's good for you to pass exams.
or rephrase:
Passing exams is good for you.
(Edit) I'm still of the opinion that, without more context, there's no way this statement represents a past event. In context, it's possible, but it would express a kind of general opinion about passing exams. A similar example:
Alma: I exercised this morning
Ben: It's good for you to exercise.
In this case, the speaker is saying, in effect:
It's good that you passed this exam, just as it's good to pass any exam.
Nevertheless, if you are talking about a past event, using the simple infinitive ("to pass the exam") is careless grammar. It sounds better to use the perfect ("to have passed the exam") or rephrase the entire sentence, is in my examples above.