According to LDS teaching, who goes to hell, and why?
I've heard that only really bad people and ex-Mormons will go to hell. Is this true?
Latter-day revelations speak of hell in at least two ways. First, it is another name for spirit prison, a temporary place in the postmortal world for those who died without a knowledge of the truth or those who were disobedient in mortality. Second, it is the permanent location of Satan and his followers and the sons of perdition, who are not redeemed by the Atonement of Jesus Christ.
LDS official teaching is that all who have died without the knowledge of truth (LDS doctrine), or that rejected the truth will go to Hell, which is very different than the widely accepted concept of Hell.
Instead of a place of suffering and torment, it's a temporary prison where they will get a chance to learn about the Truth, and if they are willing, repent and embrace the Truth.
Those who reject it are cast into outer darkness with Satan and his angels, and the "sons of Perdition".
I'll attempt to shed a little light on this:
While some refer to spirit prison as 'hell' it is not actually referred to as that in any official church teaching. It is as @David said a temporary place where people have a chance to accept the gospel of Christ. See:
1 Peter 3: 18-20
In all actuality no place in LDS teachings is actually called hell. The 'Sons of Perdition' are relegated to outer darkness, after the final judgment (as opposed to right when you die) So after the second coming of Christ.
An example of a Son of Perdition would be Cain. He walked and talked with God then rejected Him to serve the devil by killing his brother.