“He mocks.” The “He” here starts a new thought and refers to Yahweh. It does not refer back to the nearest antecedent (the righteous one in Prov. 3:33). This verse is using language that borders on the idiom of permission to communicate truth (for information on the idiom of permission, see commentary on Rom. 9:18). God does not “mock” His creation; He loves His creation, but He has given spirit beings and humans free will to make the choices they want to, and sometimes those choices are bad and bring serious consequences. When people mock God, disobey Him, and rebel against Him, they bring evil and harm to themselves, which in the Semitic way of speaking, is God “mocking” them. Not that He actually does, but since God was the one who created the universe such that evil actions have evil consequences, the Semitic way of speaking is that God “mocks” the mockers.
“he gives grace to the humble.” This verse is referenced in James 4:6. Note how it is toned down in James, which says that God resists the proud. Here, God does more than just resist those proud mockers, He mocks them.