Sex and priests

I wonder why the Church considered that priests couldn’t be married. Especially given that they were permitted to marry for a greater part of the history of the Church than the history of compulsory celibacy. Is it all to do with control? And preserving Church monies?