The core idea behind this doctrine (usually referred to as "Exaltation") is that the LDS church teaches that our spirits are literal children of God. Offspring are the same species as the parent, and can thus grow and develop to become like the parent. The idea of God once being a man, or man becoming a god, are extensions of this doctrine. This is often summarized (as @Narian quotes) via the quip "As man is, God once was; as God is, man may become."
However, there are requirements that must be met before this can happen. They are:
- having faith in Jesus Christ
- repenting of your sins
- being baptized by those holding His authority
- receiving the Gift of the Holy Ghost
- (for men) receiving the Melchizedek Priesthood
- being "sealed" to your spouse
- adhering faithfully to the Gospel of Jesus Christ for the rest of your life (which includes paying tithing, etc)
If all those requirements are met, then the LDS church teaches that such people will inherit the highest degree of glory God can offer. The Doctrine and Covenants (part of the LDS canon) describe this inheritance:
19 And again, verily I say unto you, if a man marry a wife by my word, which is my law, and by the new and everlasting covenant, and it is sealed unto them by the Holy Spirit of promise, by him who is anointed, unto whom I have appointed this power and the keys of this priesthood; and it shall be said unto them—Ye shall come forth in the first resurrection; and if it be after the first resurrection, in the next resurrection; and shall inherit thrones, kingdoms, principalities, and powers, dominions, all heights and depths—then shall it be written in the Lamb’s Book of Life, that he shall commit no murder whereby to shed innocent blood, and if ye abide in my covenant, and commit no murder whereby to shed innocent blood, it shall be done unto them in all things whatsoever my servant hath put upon them, in time, and through all eternity; and shall be of full force when they are out of the world; and they shall pass by the angels, and the gods, which are set there, to their exaltation and glory in all things, as hath been sealed upon their heads, which glory shall be a fulness and a continuation of the seeds forever and ever.
20 Then shall they be gods, because they have no end; therefore shall they be from everlasting to everlasting, because they continue; then shall they be above all, because all things are subject unto them. Then shall they be gods, because they have all power, and the angels are subject unto them.
There are places where this doctrine is alluded to in the Bible. For example:
Rev 3:21 KJV
21 To him that overcometh will I grant to sit with me in my throne, even as I also overcame, and am set down with my Father in his throne.
Here, Jesus Christ is saying that those who overcome the tribulations of the world will be seated with Him on His throne, just as He received that same blessing from the Father. A throne here can be symbolic of kingship, government, godhood, power, etc.
Rom 8:16-17 KJV
16 The Spirit itself beareth witness with our spirit, that we are the children of God:
17 And if children, then heirs; heirs of God, and joint-heirs with Christ; if so be that we suffer with him, that we may be also glorified together.
As children of God, we have the potential to inherit everything that Jesus Christ inherited, namely godhood.
The idea of polygamy in Heaven was mentioned in another answer. This is not official doctrine. I'm not aware of anywhere it's taught in the LDS "Standard Works" (OT, NT, Book of Mormon, Doctrine and Covenants, and Pearl of Great Price). I do know that early church leaders (Joseph Smith? Brigham Young? perhaps others) may have taught this, but it is no longer taught and is no longer considered official doctrine (to my knowledge). The primary answer given to questions like that is "we'll find out when we get there."