The best time to exercise is whenever you can
First of all, the best time to workout is highly subjective. I can tell you that the easiest moment to exercise is whenever you can. However, the actual best time of the day to exercise is the time you can stick with for months. Consistency is the key to gaining the most benefits from your workouts.
That being said, as decades of scientific research have shown, both morning and night workouts offer advantages.

Morning workout pros.
Morning workouts may enhance your sleep cycle: Waking up earlier to workout may seem counterintuitive for better sleep, but research suggests that morning exercise habit can shift your circadian rhythm so that your body is naturally more alert in the morning and more tired in the evening, it makes you sleep earlier so that you can wake early for your next workout. “Source:https://physoc.onlinelibrary.wiley.com/doi/full/10.1113/JP276943“
Morning workouts make your day brighter: Endorphins are produced by the body when you exercise. They are naturally occurring pain relievers, commonly named “feel-good” chemicals because they can help you feel better and put you in a good mood, which can last long after your morning workout and set you up for a nice day.

Evening workout pros.
Your metabolic health is better during evening: Metabolic health is characterized as having healthy levels of blood sugar, waist circumference, blood pressure, cholesterol, and triglycerides. Researchers from Australian Catholic University discovered that :
“guys who were overweight and at risk of diabetes had improved overnight blood sugar management when they exercised in the early evening rather than in the morning.”
https://link.springer.com/article/10.1007/s00125-021-05477
Research has shown that later workouts improved metabolic health more in people who exercised in the evening than those who did the same exercise earlier in the day.
Energy and performance tend to be higher during the day: As the day progresses, most people gain strength and endurance. Research reveals that those who exercise in the evening take up to 20% longer to reach tiredness, which means you can run, ride, or swim for longer.
“Source: https://cdnsciencepub.com/doi/10.1139/apnm-2013-0140#.XpXjYshKhPZ“
Your body is more responsive to testosterone when you workout in the afternoon: Although testosterone levels are greater in the morning, exercising in the late afternoon can cause an increase in testosterone response. Testosterone is essential for muscle growth. Furthermore, it affects both sexes’ health and well-being, including moods, behavior, and osteoporosis prevention.
“Sources: https://www.tandfonline.com/doi/full/10.3109/07420521003778773“

To sum up, according to research, the time of day you exercise might have an impact on your workout in a variety of ways. However, it is up to you to decide which one is ideal for you. Morning workouts can be a great implement for your daily routine, whilst afternoon workouts are highly effective for muscle gain and performance.