Sometime after the creation of Adam and Eve on the sixth day of creation, see Genesis 1:26-31, they rebelled against God by eating the fruit of the tree of the knowledge of good and evil.
By doing so they brought sin into the world and upon all of humanity. The details of this are in Genesis 3:1-24.
“I waited patiently for the Lord; and He inclined to me, and heard my cry. He also brought me up out of a horrible pit, out of the miry clay, and set my feet upon a rock, and established my steps.” Psalm 40:1-2.