expression
I wish I had ...; I should have ...; it would have been better if I had ...
A fixed expression of regret, formed by attaching ばよかった to the -て form of a verb. Used to express that the speaker wishes they had done something differently in the past.
もっと勉強しておけばよかった。
I wish I had studied more.
あの時、本当のことを言っておけばよかった。
I should have told the truth back then.
The general grammatical pattern for expressing regret about a past action; おけばよかった is a specific lexicalized instance using 置く as an auxiliary.
Also expresses 'should have', but べきだった focuses on duty or correctness, while おけばよかった is a softer, more personal regret.
From the -て form of a verb + 置く (as an auxiliary meaning 'to do in advance') in the conditional ば form + よかった (past of 良い 'good'). Literally 'it would have been good if I had done (in advance)', grammaticalized into a set phrase of regret.