Almost all jinja have a torii to mark the entrance, a simple gateway with two vertical pillars, one either side, and two lintels across the top. There are a number of variations in the design, but in this post I want to focus on the colour.

A red torii at a subsidiary jinja of Kasuga Taisha in Nara.
Now, at first sight it might not seem that you really need an explanation for this. Some torii are painted red, and others are different colours. Why do the red ones need a particular reason?
However, it is extremely rare for a torii to be painted any colour other than red. I think there may be some black examples, but not many, and I certainly cannot think of any examples of blue, or yellow. Almost all torii that are not red are the colour of their material. Stone torii and wooden torii are common, while metal torii are far from unknown. Stone and metal torii are almost never coloured, although the wooden torii may be treated to prevent them from rotting even if they are not red. (Those at Jingū are not, and they need to be replaced every twenty years.)
So, why that colour? The red colour is actually vermilion, which originally was a pigment made from mercury sulphide. The pigment was suspended in lacquer, making a red lacquer which is used widely in Japanese culture for important objects, a custom imported from China. Both the pigment, cinnabar, and the lacquer are toxic, which means that they are also preservatives, because they are toxic to the things that would degrade the wood as well as to people. Thus, painting a wooden object with vermilion was a good way to preserve it, as well as to make it clear that it was important. The association of vermilion with jinja is found in the Izumo Yogoto in the tenth-century Engishiki (I wrote an essay about this for my Patreon in December), and red lacquer is still found at a number of jinja. If it is genuine, the jinja is rich, but imitation red lacquer is also not uncommon.
Thus, at a basic level, the vermilion colour of torii was a way to preserve wooden torii while making their importance clear. However, it was an expensive way to do that, so it never became universal. (It was probably cheaper to replace the torii when necessary.)
I suspect that the current situation was also influenced by the changes to Shinto imposed in the late nineteenth century. The red lacquer had an association with China, and with later culture, and was not used at Jingū, or in the Daijōsai, two ceremonial sites that were touchstones for “real Shinto” to people of that period. Thus, I think there may have been a move away from using vermilion on jinja or torii in that period, leading to the large number of uncoloured torii we can see today.

A red torii at a subsidiary Inari Jinja at Hie Jinja in Tokyo
Today, you can get torii made of construction plastic in vermilion colour, and these are quite common. Thus, it is impossible to say anything general about the reason why a particular torii is or isn’t red. In some cases, it is red because the jinja enshrines Inari. In others, the jinja is old and wealthy, and has always had vermilion torii. In still others, it was simply the personal taste of the donor or the supervising priest.
This is something that seems as though it ought to be really important and symbolic, but which is, to the best of my knowledge, not.