Our Heavenly Father loved us so much that he wanted to share all that had with us. Consequently, He created a plan for us. So, we could become like Him. If we followed this plan, we would come to earth to gain a body (like Him) and be tested to prove we were worthy to return an live with him.
As part of this test, we would pass through a veil that would cause us to forget our past life with our Heavenly Parents. We would then be given the freedom to choose, act, and live however we wished. God would test us to see whether we would seek to know Him, love Him, and obey His commandments (or not). We would have the opportunity to learn, grow, and have experiences that were never possible for us previously. We would be given the opportunity to become parents ourselves and have children–A test to see how well we would do. We would be given the freedom to choose however we wanted to live our lives.
Our, all knowing, omnipotent, Heavenly Father knew that we would not live perfect lives though. And, in order for us to return and live with Him again, we needed a way to repent and “become clean” again.