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?
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:
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.