~のに portion often contains よかった (past regret) or a counterfactual result clause.
The structure ば~のに expresses regret, disappointment, or frustration about something that didn't happen (or isn't the case). It conveys the feeling of "if only…" or "it would have been better if…". The speaker wishes that a different action had been taken or a different situation existed, implying that the actual outcome was unfortunate.
When talking about past events, ば~のに expresses that something should have been done but wasn't, and the speaker regrets it.
In this usage, the past tense appears in the result clause (before のに), while the ば-form itself remains unchanged. The particle のに at the end carries the emotional weight of regret or frustration.
ば~のに can also express a wish about a current situation that isn't true, similar to "if only…" in English.
The pattern ~ばよかったのに is extremely common and functions almost as a set phrase meaning "should have done…" or "it would have been nice if…". It can be directed at oneself (self-regret) or at someone else (mild reproach).
When directed at another person, it carries a tone of gentle blame – "why didn't you do that?"
~ばいいのに (without よかった) expresses a present or future wish – something the speaker hopes will happen or wishes were currently true. ~ばよかったのに looks back at the past with regret.
Compare: