This question has no simple answer and is one of the reasons we were given A Course In Miracles. The Course gives us an understanding and a basis to accept the fact that the universe and everything that seems to be in the universe is just a common dream that we are all having in the one and only mind we all share; but like all dreams, it has no basis in reality, i.e., there is no physical universe in eternity. Once we accept this fact, it is simple logic to realize that no one can sin in Truth, but we can appear to do so in the dream of space and time and that dream is just an illusion.
“God’s Will for me is perfect happiness.
⁷There is no sin; it has no consequence.” (ACIM, W-101.6:6-7)