A by-law is like a set of rules made by a group of people to help them live together happily. Just like your parents might make rules for you and your siblings to follow, different groups like cities, towns or buildings make rules too.
For example, a building might have a by-law that says you can't make too much noise after 10 pm, because people might be sleeping. Or a city might have a by-law that says you can't litter, because that's not good for the environment.
By-laws are important because they help make sure everyone plays nice and follows the rules. And if someone breaks a by-law, they might get in trouble with the group that made the rule.