The Catechism in Questions & Answers

87. Were the first human beings allowed to do as they pleased without restriction?

No. As the Creator, Lord, and Lawgiver, God gave Adam and Eve the commandment not to eat of the tree of the knowledge of good and evil in the garden. In so doing He tested man to see how they would deal with the freedom of decision that had been conferred upon them as the image of God. At the same time He warned them about the consequences of violating this commandment.

Image of God: see Question 81.