Judaism teaches that Hashem wished to do good, so He created beings that could appreciate it.
It means that Hashem created humanity to enjoy a relationship with Hashem, that we experience the ultimate pleasure of the Presence of Hashem. Ultimately, humanity wants pleasure. We understand the concept of pleasure,
because Hashem has given us that ability in this world. Yet all the greatest pleasures of the universe compacted into one thrilling moment can never be even one millionth as pleasurable as the ultimate experience of the World to Come.
So, ultimately, humanity, the thinking beings in this world, were created to receive good.
However, Hashem wanted those beings to appreciate the good in the best possible way, so He made them have to work for it.
If given a choice between working for a living or being supported by someone else for free, most people would choose working for a living. We prefer not to have to live on gifts, or on welfare.
If we received the ultimate good, reward in the World To Come, without having to work for that good, we would not enjoy it at all. In fact, it would be embarrassing. The Talmud calls it nahama dich’sufa, the «bread of embarrassment.»
That is human nature. We want to fully enjoy what we deserve, and we want to fully deserve what we enjoy.
In this sense, Hashem created us in His image. It is impossible to give anything to Hashem, because everything comes from Hashem. Hashem cannot receive something for nothing. Hashem must create it first.
Similarly, our very nature demands that we do something to receive something. Just as Hashem cannot get something for nothing, Hashem created us in that image.
So we have to work to attain the good that He has prepared for us. Hashem therefore created two worlds. In This World we work to attain a close and spiritual relationship with Hashem. In the Next World we enjoy that relationship to the fullest.
It is possible, even in this world, to experience a semblance of that Future Reward, as we develop our relationship with Hashem. But the fullest experience of that reward will be only in the Future World.
The Talmud therefore says, «Today is for doing the work; tomorrow is for the reward.»
How do we work for it? We fight the temptation not to do what we are supposed to do. We choose between working for that good and doing things we shouldn’t do. That is the work of our lives.
In This World we study Torah and perform the Mitzvos, in the Next World we will reap the reward.
That is the reason that Hashem created the world.