The answer to the question about why God is referred to in masculine terms in the Bible really has only one answer: This is the way God has chosen to reveal Himself to us. God is never described with sexual characteristics in the Scriptures, but He does consistently describe Himself in the masculine gender.
While God contains all the qualities of both male and female genders, He has chosen to present Himself with an emphasis on masculine qualities of fatherhood, protection, direction, strength, etc. Metaphors used to describe Him in the Bible include: King, Father, Judge, Husband, Master, and the God and Father of our Lord Jesus Christ.
One famous Christian scholar, C. S. Lewis, has suggested that gender is far deeper than our human distinctions reveal. He suggests that God is so masculine that we all are feminine in relation to Him. If this is true, it might explain why the church is referred to as the bride of Christ, though it is composed of both men and women.
There are those who would like to blur this emphasis in some of the newer Bible translations, but it is very dangerous to tamper with the way God has chosen to reveal Himself. He most certainly does not intend to minimize women, since men and women are revealed as being made in His image and are of equal value to Him. But it remains that He is Father, not Mother, and even in the Incarnation chose to come to us as a man, Jesus Christ.