In Peter the Great's case it was to do with trying to bring Russia more in line with Western European models.
More precisely Peter the Great introduced a tax on beards which existed for about 70 years until Catherine the Great overturned it. This was in direct attack against the Russian orthodox church of the time, because he wanted to westernize the country (and he needed more money). Having paid the tax bearded people carried a token around with them - if they didn't have this then they could be force shaven by the police. There is a persistent idea that Henry the VIII did the same in England though historians have been unable to prove this. The Kingdom of Yemen introduced a tax in 1936 for all men over eighteen who didn't have beards ! Some Islamic countries have inflicted punishments on the unbearded but Yemen thought that there was money to be made through this ! Over to you !