Barns are red because of an abundance of iron from exploding stars.
Barns get painted because it helps protect them from the elements where, if left untreated, they would rot. In the spirit of Louis Sullivan that “form follows function”, barns are painted for practical reasons more so than artistic ones. Red was originally chosen because it was the cheapest paint. It was the cheapest paint because of exploding stars.
Iron is the most abundant element on Earth, making up 32.1% by mass. The iron on rocky planets such as Earth came from red giant stars which produced iron atoms towards the end of their lives. Once a star is producing iron it’s on a one-way ticking timeline towards going supernova. When the star finally explodes it sends elements across space, including iron.
Fast-forward billions of years, in the mid 19th century American farmers began painting their barns with homemade paint. Farmers mixed skimmed milk, lime, linseed oil, and the readily available red iron oxide found in clay soil to create red paint. Red paint protected the wood from rot as well as from mold since iron oxide (rust essentially) kills mold. By the late 19th century when commercially produced paints were more widely available red paint was still cheaper than other colors and so farmers continued painting their barns red. Today barns are painted red largely out of tradition.