Giving advice with 〜た+方がいい
When attached to the た form of a verb, 方がいい means that something else would be better (to do). It is similar in meaning to the English “had better do”.
Alternate explanations
The た form of a verb, followed by the phrase 方がいい, is used to give advice. It corresponds to the English ‘had better do’. The sentence-final particles ね and よ are frequently used when giving advice, either to soften a suggestion (ね) or to give force to it (よ).
Kamiya, Taeko. “Commands, Requests, Suggestions, Approval, Disapproval, Prohibition, and Obligation.” Japanese Sentence Patterns for Effective Communication, Kodansha, 2005, p. 170
This pattern shows how to give advice, make a suggestion. This is done with the phrase 方がいい preceded by a verb in the plain past tense. 方がいい literally means ‘alternative is good’. The alternative being suggested is obviously the one expressed by this phrase, but the other alternative often remains unspoken. The unspoken alternative is often simply taking no action at all. The subject of this pattern is 方 (marked by が), and the topic is the person to whom the advice is being directed (marked by は); since this person is often ‘you’ or ‘I’, it is frequently omitted as being understood form context.
Chino, Naoko. “Basic Pattern 40.” A Dictionary of Basic Japanese Sentence Patterns, Kodansha, 2000, p. 233