Is it a sin to marry your cousin's ex-husband? Does God agree with this?
You don’t give me enough information to answer directly. I will answer for four possible situations.
First, if the man is her ex-husband because she died I can find no scripture to forbid such a marriage unless he is also a close relative of yours. The Law of Moses prohibited marrying the widow/widower of certain close relatives, but not of a cousin of any degree. No mention is made of similar provisions for those not under the Law of Moses.
The next three situations are covered by Matthew 19:9. (1) If he is her ex-husband because he divorced her because of her infidelity, then he is free to marry whomever he wills. (2) If he is her ex-husband because he divorced her for any reason other than “fornications” then he is not free to remarry, and to marry him would be adultery in God’s eyes. (3) If he is her ex-husband because she divorced him for any reason then he is not free to remarry.
In that last case, if she divorced him because of his adultery then it would not only be unscriptural but unwise to marry him. Besides being called adultery, it would be setting yourself up for the possibility of him cheating on you as well.