An interesting thing to note about Job's friends is that although they are rebuked and commanded to repent, a lot of what they say is actually true. The concepts they describe are brought up later, and in some cases, later Scripture even cites their words as God's.
Job 5:17 is an excellent example of the former. Eliphaz claims that God's correction and chastening is for our benefit, a concept later described in Hebrews 12, verse 6 in particular. Correction from God is a good thing. However, even here Eliphaz' theology is flawed. His reasons for telling Job not to despise God's chastening is because he assumes this is what's going on. He believes Job has done something wrong, because in his view, no one can suffer without doing wrong. However, such thinking is flawed. We, as the readers, know the real reason Job was suffering. It wasn't God punishing him, but rather God had permitted Satan to test Job's faith. A test in which Job was actually doing remarkably well.
Sometimes, we do the same thing as Eliphaz. We give advice that would normally be good, but isn't applicable in the current scenario. To give an example from my personal life, many people advise me on numerous ways to ensure I sleep better at night. The advice people give me is usually good, such as turn screens off early. However, because I have a sleeping disorder, these sleeping techniques do not work. Ironically, even coffee, which would normally wake people up, has a high, though unfortunately not invariable chance of sending me to sleep.
Eliphaz has his good points and his bad points in this scenario. What he did right was that, first of all, he trusted God. He believed doing good was good, and that it is good to accept God's chastening when we do bad. What he did wrong, however, was to make assumptions with incomplete information, and to give advice based on those assumptions. As Christians, we should be aware that even our most well-intentioned advice can actually have the adverse effect if taken.
I particularly like this about Mike Winger, a popular pastor who does Q&A livestreams on YouTube. Every so often, he'll get a more personal question. "Hey, my husband's doing this", "hey, my church is preaching that", "should I leave?" So Mike always lays out general principles, but also advises a closer counselor should be brought in. Someone who can sit down and gather all the facts. This is a wise approach, and a good example to follow.
The principle Scripture puts forward here is that we should always be slow to speak and quick to listen (and of course, slow to anger). Assumptions are very often wrong, which leads to even a true principle leading to a false conclusion. Our conclusion, therefore, is that since God gave us one mouth and two ears, we should use the latter more often.