Well, first of all, European farmers from a long time ago used a form of linseed-oil (from a flax plant) mixture as a wood sealant to protect the barn. Then, they would add ferrous oxide (aka rust) to the mixture because it is very common and acts as a poison to many types of fungi (like mold and moss) that grow easily on barns. Rich farmers would also add blood (from dead animals) to the mixure- darker red. After the Europeans brought this red barn/rust-linseed idea to America, it became a fad. And when pigmented paint was first created, red paint was cheapest to buy. So now we are left with century-old fad. Even though a lot of farms nowadays don't have red barns.
Sounds plausible. It still seems to be fairly common in Scotland. Another possible reason is that red makes it easy to see the barn from a distance and so get your bearings. I also note a lot of tractors are also painted red.
How interesting. My barn is green but then I've never been much of a conformist. That seems to have been an excellent answer at the first hit and I have nothing to add except that I found the question interesting as a person with a barn.
There were two colors of paint stocked by hardware stores or ordered from a catalog by a farmer . . . white or red. The pigment in the white paint was basic lead carbonate and in the red paint it was lead tetroxide. Houses and outbuildings white . . . the barn red.