Ultimately, logic is a creation, no less a creation than trees, mountains, sky or planets. Therefore, to ask why the universe was created is artificial. Questioning "Why?" presupposes the the presence of logic. However, logic was not yet created at the initial impulse of creation. It was awaiting it's creation along with the trees, mountains, sky and planets. In a sense, it's like asking a child why did he birth his own father? A serious confusion of cause and effect.
Yet, we see that the Jewish mystical sages have advanced various reasons for the creation of the universe. Probably, because they were trying to approximate within the more limited scope of logic the initial impulse of creation, even if imperfectly. However, at best it's like trying to capture vivid color on black and white film. It's unclear what colors the shades of grey really attempt to convey. It's a beautiful impression cast on an inadequate medium, leading to a imperfect result. So why did the sages seek to convey this unbounded initial impulse logically? Why fetter this impulse in chains of logic? Why not leave it free? Quite possibly because whatever a person thinks the goal of creation is will serve as the core of his/her spiritual focus and ultimately, as the hub of all his/her spiritual activity.
However, because of logic's inadequacy to serve as the measuring rod of what had existed in a pre-logic environment, there are quite a few correct answers to this question; as no single answer seems to express the full story. One of my favorite reasons for creation is advanced at right at the onset of the holy work, "Tree of Life", by Rabbi Chaim Vital (1543-1620) - the closest disciple of the most celebrated Kabbalist Rabbi Isaac Luria (1534-1572). I will allow the power of his words to speak on their own (the brackets are my own):
[The Sages] said that the reason [for creation] was because He needed to be complete in all his deeds, latent potentials and in all His names of greatness, esteem and honor. Had He not brought out His capacities and latent potentials into work and deed, it would be, as if, He would not have been called "complete", neither in His deeds, nor in His names, nor in His appellations.
So too with the name "Adnus" [i.e. Mastery]. He's called so because [the name] demonstrates mastery. He has servants and He's a master over them. If there weren't created beings, He would never be able to be called by the name "Master". Similarly, with the rest of the names.
The same would apply to His appellations, like: compassionate, graceful and patient. He would not be called by them unless the world is populated with creations. It is only then that His working and latent potentials can emerge, allowing Him to be called "whole in all His workings and latent potentials", as well as, "whole in all His names and appellations", without any imperfections, heaven forbid.
This underlying reason for creation is well founded in the Holy Zohar (see Parshat Pinchas P.257B), "The 13th commandment is the Shema affirmation. It's meant to be known that He is called wise in all kinds of wisdom and understanding in all kinds of understandings ... However, before He created the world, He was referred to by all these levels on account of the creation which He will later create. For if the world wasn't going to be populated with creations then why would He be called compassionate or judge? It could only be on account of the future creations..."
Another similar quote in the Holy Zohar (see Parshat Bo P.52), "Had His light not been cast over all His creations, how would He be known, how would the verse (Isaiah 6:3) '...His glory fills the entire earth' be fulfilled?"