Religion is a fundamental set of beliefs and practices generally agreed upon by a group of people. These set of beliefs concern the cause, nature, and purpose of the universe, and involve devotional and ritual observances. They also often contain a moral code governing the conduct of human affairs.
Ever since the world began, man has demonstrated a natural inclination towards faith and worship of anything he considered superior/difficult to understand. His religion consisted of trying to appease and get favors from the supreme being he feared. This resulted in performing rituals (some of them barbaric) and keeping traditions or laws to earn goodness and/or everlasting life.