Job 42:2 I know that thou canst do every thing, and that no thought can be withholden from thee.
Job 42:3 Who is he that hideth counsel without knowledge? therefore have I uttered that I understood not; things too wonderful for me, which I knew not.
Job 42:4 Hear, I beseech thee, and I will speak: I will demand of thee, and declare thou unto me.
Job 42:5 I have heard of thee by the hearing of the ear: but now mine eye seeth thee.
It's only natural that after Job realizes that he has spoken things he did not understand that he then repents:
Job 42:6 Wherefore I abhor myself, and repent in dust and ashes.