The rationale about the sin of masturbation, in general, is what is now called the theology of the body.
We have to remember as scripture says that the world and all that is in it belongs to God – including our bodies. (right away, this flies in the face of the abortion lobby which carries signs that say “our bodies, our choice” – right out of the chute, abortion is a denial of God and scripture, but I digress).
God ordained that the sexual functions are intended for the context of marriage. Notably, in the Old Testament, when Onan “spills his seed” it is evil on several levels: it frustrates the law of the levirate in Judaism, it frustrates the purpose of openness to reproduction and creation, it frustrates the will of God, to multiply and fill the earth, for example.
We are made in the image and likeness of God, and so an abuse of this function takes away from our God-given dignity and our destiny to be with God forever.
Especially through Baptism, Reconciliation, and the Eucharist, we are engaged in the process called “divinization” – another word, generally, for salvation – where we do not become gods, but we come to be as close as possible to having a God-like character. God loves this, because when He looks at us, it is a reflection of Himself.
The theory or basis of all of this is also expressed as the universal call to holiness. We are ALL called to be holy, as God is holy. Our reproductive capability in marriage get us very close to working with God in His will of creation. In Chap 3 or 4 of Genesis, Eve makes a critically important observation, that she has produced a child “with God” indicating how close and aligned the reproductive faculty is with God’s will. (She seems to give Adam little or no credit for helping to produce the child, but that omission is besides the point.)
When you consider our common destiny to face Christ as the Judge, what will you (and the rest of us) say to Him (how can we argue with God) ?