Why did God want or need a relationship in the first place? I understand that God is all powerful, knowledgeable, and any other attributes you could assign to Him, so why did He need man? He spent endless "time" existing before man. Why create us now?
While Scripture does not explicitly answer this question, we can find helpful answers in well-known statements of theology, which are backed by Scripture. For example, the Westminster Confession answers your question as follows:
“What is the chief end of man? Man’s chief end is to glorify God, and to enjoy him forever.”
The Confession cites the following as supporting Scriptures: Psalm 86; Isaiah 60:21; Romans 11:36; 1 Corinthians 6:20, 10:31; Revelation 4:11; Psalm 16:5-11; Psalm 144:15; Isaiah 12:2; Luke 2:10; Philippians 4:4; Revelation 21:3-4. We agree with the Confession here, and would add that we believe that God desires a relationship with man so He may be glorified (please refer to above Scriptures) and to allow Him to demonstrate all of His perfect attributes to an audience that can appreciate them. In the demonstration of God’s character through these attributes, we come to know and glorify God.
For example, Jeremiah 9:23-24 says:
Thus says the LORD, "Let not a wise man boast of his wisdom, and let not the mighty man boast of his might, let not a rich man boast of his riches; but let him who boasts boast of this, that he understands and knows Me, that I am the LORD who exercises lovingkindness, justice and righteousness on earth; for I delight in these things," declares the LORD.
Notice that God desires us to understand and know Him, and part of this knowledge is in what He does and who He is. If we understand and know someone, we know what they are like, what kind of person they are. God likewise desires a close, intimate relationship with us whereby He can make Himself known.
God even endures the existence of sinful creatures who were prepared for destruction in order to demonstrate His power, wrath and justice. Romans 9:22-24 says:
What if God, although willing to demonstrate His wrath and to make His power known, endured with much patience vessels of wrath prepared for destruction? And He did so to make known the riches of His glory upon vessels of mercy, which He prepared beforehand for glory, even us, whom He also called, not from among Jews only, but also from among Gentiles.
Of course, this also demonstrates His great love and mercy for us who are called.
So, we see that God desires for us to know Him, to know His character, and to understand Him. We come to know Him as He reveals His personal attributes, including His love, mercy, grace, justice, and wrath. While we may not have a totally clear answer in this life as to why God created us, it’s something to which we can look forward to asking Him in heaven. For our time on this earth, may our Lord God continue to empower us to bring Him glory and honor in everything we do.
As we’re commanded in 1 Corinthians 10:31 - Whether, then, you eat or drink or whatever you do, do all to the glory of God.