it is a 形容詞 (i-adjective) with meanings relating to 'good' or 'nice', generally positive vibes.

has two readings: いい・よい

いい

Is informal Cannot be conjugated.

いい友達 A good friend

それがいい That's good.

よい

is formal

よいお嬢さんでした A good girl

Can be conjugated.

それがよくない That's not good.

If only (...)

Combined with 〜ば (Maybe generally conditionals, but 〜ば is most common) , shows that another way would have been better.

Regret

For past tense 良かった, this is roughly expressing regret

そうすればよかったI should have done that.
lit. if I had done that, it would have been good.

もっと早く家を出ればよかったI should have left the house earlier.
lit. if I had left the house earlier, it would have been good.

友達にあんなことを言わなければよかった I should not have said such a thing to my friend.

It would have been better if

Like Regret, but now more objective: along the lines of "I should have done X"

薬を飲んだ方がよかったよ It would have been better if you had drunk the medicine.

ちゃんと謝った方がよかったです You should have instead properly apologised.

It is ok if I (A)

expresses that something is allowed.

〜て Also, even 良い

もう家に帰ってもいい You are allowed to go home now

クーラーをつけてもいいですか? Is it ok if I turn on the heater?

the いい can also be something like 大丈夫、かまわない

明日は休みを取っても大丈夫 It is okay for you to take a rest tomorrow