Why should I cook the flour first with butter, instead of just combining all the ingredients until I get the desired consistency when making a bechamel sauce?
This link explains the science behind what is known as "the mother sauce", béchamel. Essentially, the steps of first creating a roux, then adding cold milk, are about manipulating the glucose chains in the flour. Done correctly, the sauce is smooth and flavorful. Done incorrectly and you have a grainy mixture that tastes of raw flour.
@David Richerby's comment below prompted me to investigate further. So, I turned to Harold McGee's classic, On Food and Cooking. He writes, on page 617, that:
in addition to coating flour particles with fat, making them easier to disperse in a hot liquid, roux making has three other useful effects on flour....it cooks out the raw cereal flavor, and develops a round, toasty flavor...second, the color itself...and third, heat causes some of the starch chains to split, and then to form new bonds with each other.
He goes on to explain the importance of this step, but it generally achieves the desired texture and means the sauce is less likely to congeal on the plate.
Starch or amylum is a polymeric carbohydrate consisting of a large number of glucose units joined by glycosidic bonds.
...and, yes, this correlates with gelatinization.
Flour has to be cooked in any kind of fat, butter or oil to remove the rawness of the flour. If you don't roast and put all the ingredients straightway and cook for longer time, it would still work, but in that case you'll have to cook for bit longer and reduce the ratio of flour. Otherwise the sauce will thicken up and it would taste raw as it wasn't cooked.
It's very difficult to just mix flour with a liquid. It will set to the bottom of the sauce pan and clump when heated, unless you stir constantly.
This is why you make a roux first, combining the flour with some kind of fat. You could just mix flour with cold butter until well combined and add it to hot liquid such as milk and it would thicken just fine (I use this technique when I want to thicken a sauce when it's almost done and i find it a bit too runny.)
However, by first heating the oil and flour you take the raw edge of the flour as well, or even give it a nice toasted flavor profile, which is desired in many cases.
It is important that after "frying" the flour and fat you turn off the heat and add the first liquid (water, stock, milk) slowly while stirring. Later you can add liquid more quickly and turn the heat back on. In common with the other answers: this avoids clumps.
I sometimes make a roux from peanut butter, flour, spices, milk, water. Yummie. Without the extra flour there would be too much peanut oil. Mixing hot oil / fat / butter with the flour first gives you an idea of the right proportions, it has to form an almost-dry ball.