The Olympic Charter was created in 1908 and in 1975 a clause(Olympic Rule 50) was added that states that no political meetings or demonstrations can be held in the stadium where the Olympics are held. The Olympics are an event that brings attention from all over the world for sports and if an athlete engages in a political protest of any sort it can have a damaging impact in a variety of ways, especially for that athlete. This means that every kind of propaganda or demonstration, even if it is religious or racial etc, is forbidden at the Olympics. Olympic Athletes are discouraged from using the Olympics as a platform to convey religious or political views.
The basic structure of that was written into the Charter years ago and it broadly went on to stipulate that no demonstrations of any sort in political nature would be tolerated. There are countries taking part in the Olympics from all over the world, as well as watching from around the world too. And this rule is to make sure that the focus of the Olympics is on competitive sports and not about political or religious agenda.
There had been a history of some protests taking place at the Olympics before those rules came into place. For example, in 1906 they saw political protest action, and there have been some full boycotts of the Olympics too over the years. The first boycott was in 1956 for the Summer Olympics and then more recently we saw that there had been a boycott of the Olympics in 1988.
The Olympics have been an opportunity for athletes from around the world who take the stage in front of the globe to be able to demonstrate and some have taken that chance. This is why rules were later updated to stipulate that this sort of behavior would not be tolerated because they want it to remain about the sports and not turn into a show with political stunts.