Why does society have rules?

If there were no rules think about it: Everyone doing anything and everything they want at the same time would ensue chaos thus rules are needed. Remember that without the rules of society, murderers, rapists, and republicans would do as they wish