Since God wanted fellowship, and not a "robot" companion, He gave man free will. That is, man was free to choose whether or not to fellowship with God. Man had every reason to do so; his Creator loved him and provided a perfect home for him. In fact, the only thing that God required of man was not to eat the fruit from one tree in the garden that God made as man's home.
Unfortunately, man was deceived by God's enemy, and chose not to follow God's command. Because God is perfect, He could not allow man to remain in His presence, and thus man was separated from God.