[来る → くれ] + ばよかった
[verb ない → なけ] + ればよかった
Note: Affirmative = regret about not doing; Negative = regret about doing.
The structure ~ばよかった is used to express regret about something that was not done, or a wish that things had gone differently. It translates to "I should have…", "I wish I had…", or "it would have been better if…".
It is formed by combining the ば-conditional form of a verb with よかった (the past tense of いい/よい), literally meaning "it would have been good if…".
The most common use is to express regret that you didn't do something.
To express regret about something you did do, use the negative ば-conditional (なければ) + よかった.
Adding のに at the end strengthens the feeling of regret or disappointment, implying "…and yet (things didn't turn out that way)."