The story of paganism begins after Noah’s flood with his son Ham and Ham’s grandson Nimrod. If you remember the story of Noah’s flood, the people on earth were extremely evil and so God killed everyone who wasn’t on Noah’s ark by flooding the earth. This would have left a very strong impression on Noah and his descendants (the Patriarchs) that God wasn’t someone to be messed with and that He should be obeyed and worshipped.
However one generation down the family tree starting with Ham, people started rebelling against God’s laws again and the guy who really got things going was Nimrod. We pick up the story in Gen 10:8-12: