Answer: Chazal instituted (see Shulchan Aruch 531:1-2) that one mustn’t take a haircut on Chol Hamoed. Rabbeinu Tam wrote that since the Gemara’s reason for the prohibition is to ensure that people will take a haircut before Yom Tov, if one did in fact have a haircut beforehand, he may do so again on Chol Hamoed.
The majority of the Rishonim reject this opinion. Firstly, others won’t know that he shaved before Yom Tov, and secondly, the Mishna (Moed Katan 13b) and Gemara don’t make any such exception.
The Noda Biyehuda (1:13 & 2:99-101) allowed one to shave on Chol Hamoed providing that the barber employed was destitute and needed the money to eat.
This innovative responsum caused quite a stir. The Chasam Sofer (OC:154) strongly disagreed, saying the Gemara is clear that it is forbidden, and laxity in this will lead to further transgressions.
R’ Moshe Feinstein (Igros Moshe OC 1:163) wrote that based on the Noda Biyehuda he could allow one who shaves regularly to shave on Chol Hamoed, too. As nowadays people shave so often, we don’t need to be concerned that people will mistakenly think that he hadn’t shaved prior to Yom Tov. As frequent shaving simply wasn’t the norm back then, the Gemara didn’t mention it. Even those who disagreed with Rabbeinu Tam would agree that nowadays it is permitted to shave.
He ends, however, by saying that this applies specifically if one has a strong need (e.g. it may jeopardize his job) or if it causes one particular discomfort to go unshaven.R’ Yehoshua Neuwirth (Shemiras Shabbos Kehilchasa, 1:p264) among others, concurs with the Shulchan Aruch and Chasam Sofer and forbid one from shaving on Chol Hamoed even if he’d done so before Yom Tov.