This is no longer true, (if it ever truly was). One cannot,*still*, become a Cardinal, however.
The reason was, unfortunately, pragmatic.
The concern was clergy having children in unmarried unions, then placing these children into the priesthood or elevating their children within the hierarchy as a form of 'inheritance', or passing down one's clerical office to one's children as an end run around celibacy and thus of not having heirs. Since these children were nominally 'illegitimate' (since the priest was clearly not married) this rule was created/enforced.
This has long since been relaxed, even eliminated, except for the prohibition on becoming a cardinal.