In a medium saucepan, whisk to combine the sugar and the flour.
Pour in the milk while whisking constantly until smooth.
Cook the milk mixture over medium heat, whisking frequently, until it starts to simmer, 5 to 7 minutes.
Reduce the heat to medium-low and hold it at a simmer, while whisking constantly, until the mixture thickens like pudding, 1 to 2 minutes. Remove it from the heat.
Pour the mixture into a medium bowl and press plastic wrap into the surface so that a skin does not form. Let it cool to room temperature, for about 2 hours. (You can speed this up by putting it in the refrigerator, just make sure that it only cools to room temperature.)
In the bowl of a stand mixer fitted with a paddle attachment, beat the butter on medium speed for 2 minutes until smooth and creamy. Scrape down the sides and bottom of the bowl.
To the bowl with the butter, add the cooled flour mixture 2 to 3 tablespoons at a time, mixing on medium-low speed until fully combined, in between each addition.
Add the vanilla and food color, if using. Increase the mixer to medium speed and beat the mixture for about 1 minute, until the filling is smooth, light and airy. (The frosting should be very thick.)