Overall, the best time to visit Angkor Wat is October, before 9am and between noon and 2pm. This is based on when the dry season is, monthly temperature, and tourist arrival numbers. I'll talk in more depth about these factors below
The time of the year at Angkor Wat with the best weather is from November to February because this is the dry season in Siem Reap with the lowest number of rainy days and manageable temperatures. Since Angkor Wat is all outdoors sightseeing, you don't want to deal with the rain and the muddy grounds that come with it. Plus, one of the major draws of Angkor Wat is the sunrises and sunsets, which can be ruined by a rainy day.
From a temperature perspective, you want to avoid March to May because this is the hottest time of the year. April and May is probably the worst time to visit from a weather perspective because it's both hot and humid, not a very good combination for your sanity
Unfortunately, the months with the best weathers are also the months with the biggest crowds. The tourist peak seasons at Angkor Wat is December to March, as you can see from this chart I built using the official data from Angkor Enterprise, which is the government-run agency that operates Angkor Wat:In the rainy seasons from April to October, the number of visitors is about half of the peak months. Late October is actually very nice because rainy season is drawing to a close and tourist peak season hasn't quite arrived yet. So you get a higher chance of nice clear skies without that many tourists
While it's impossible to avoid crowd at Angkor Wat (after all it is the biggest attraction in Cambodia and one of the top attractions in Southeast Asia overall), there are steps you can take to minimize the crowd issues even when you visit during the peak months. It comes down to what time of the day to visit various temples:
The main Angkor Wat temple: it will be crowded from sunrise to sunset no matter what, so the best you can do is to be one of the first people to get there so stake out a good spot to watch the sunrise. Sunrise varies from 5:40am to 6:30am throughout the year, use websites like Time and Date to plan. You should get to Angkor Wat right at opening at 5am to get the best spot available
For all temples: the time immediately after sunrise and before 9am is fantastic because most tourists are still getting ready, and even many in the sunrise crowd went to get breakfast, so the temples are relatively uncrowded. After 9am busloads of tourists start to arrive at all temples making them very crowded. Then, around lunchtime between noon and 2pm there seems to be another lull in tourists, so this is also a great time to take pictures without too many people in your frame
For sunset: while not as popular as sunrise, many tourists also stick around to see the sunset at one of the temples. There are only 2 temples open late enough to see sunsets at: Phnom Bakheng and Pre Rup, both of which open until 7pm while all other temples close at 5:30pm. The sunset crowd starts to stream in from around 1.5 hours before sunset, which ranges from 5:34pm to 6:35pm throughout the year (again, use websites like Time and Date to check and plan). So you want to plan accordingly and arrive early to have a good spot.
By the way, for sunset I recommend seeing at Pre Rup instead of Phnom Bakheng because Pre Rup is much less crowded due to its remote location. But what really makes Phnom Baheng terrible for sunset is that it limits the total number of visitors to 300 at any given time, so there's a huge line up to climb up there a full 2 hours before actual sunset, and you're not guaranteed to be even a be able to allowed to go up come sunset time unless you start queuing like 2-3 hours before sunset (during the peak season). Anyway, I saw sunset at Pre Rup and this is what it looked like: