It is unpleasant because it is not what we expected to encounter.
Is there any guarantee that what we originally expected would be better?
Could this experience be equally good or equally bad?
If this is happening, its causes and conditions must be present.
If its causes and conditions are present, it is unavoidable.
If it is unavoidable, it is necessary for it to happen.
If it is necessary, it is beneficial, at least as a lesson in cause and effect.