Short version: The rule is about appearing nice, clean-cut, and respectable in line with current cultural norms. It's a matter of practicality - just look nice, in order to better represent the Church and therefore, God.
From an address President Dallin H. Oaks gave to the 25,000 students of Brigham Young University.
Unlike modesty, which is an eternal value in the sense of rightness or
wrongness in the eyes of God, our rules against beards and long hair
are contemporary and pragmatic. They are responsive to conditions and
attitudes in our own society at this particular point in time.
Historical precedents are worthless in this area. The rules are
subject to change, and I would be surprised if they were not changed
at some time in the future. But the rules are with us now, and it is
therefore important to understand the reasoning behind them.
In the minds of most people at this time, the beard and long hair are
associated with protest, revolution, and rebellion against authority.
They are also symbols of the hippie and drug culture. Persons who wear
beards or long hair, whether they desire it or not, may identify
themselves with or emulate and honor the drug culture or the extreme
practices of those who have made slovenly appearance a badge of
protest and dissent. In addition, unkemptness—which is often (though
not always) associated with beards and long hair—is a mark of
indifference toward the best in life.