There is no one factor that singlehandedly causes us to obey the rules. In most cases, there are a few different factors that help to cause us to obey. Some of the most important factors are fear, convenience, and respect for authority.
At times, we obey the rules simply because we are afraid of the consequences of disobedience. Many kids in schools fear detention so they obey the rules. Many drivers obey the speed limit because they fear the fines and higher insurance rates that come with speeding tickets. Many religious people obey the rules of their religion because they fear God’s retribution for sins. These people obey the rules out of fear.
At times, we obey the rules because it is convenient. Most of the time, the rules are not that hard to obey. It is not that hard to drive 30 mph down a street as opposed to 45. Speeding will save you very minimal amounts of time and is just not worth it. It is not that hard for most of us to, for example, avoid breaking the rules by stealing. Since most rules are not that hard to obey, we tend to obey most rules most of the time.
Finally, we might obey the rules because we respect authority. We might believe that obeying the people above us is generally the right thing to do. Our parents and our teachers generally bring us up to believe that we should usually obey authority. So, we might obey the speed limit simply because we think that it is right to obey rules made by the government.
All three of these factors can help cause us to obey most rules at most times.