As a child, I was "protected" from funerals. I have no doubt my parents did what they thought was best...however, in hindsight, I think my parents did me a disservice when at age eight they kept me away from my grandfather's funeral.
I like how swaimj handled things. Obviously, there needs to be great care taken, especially on the young end of the spectrum. But, it's a great place to teach them (in a small, brief, controlled way) the lessons of life and death, and (if the deceased was a Christian) about the great hope we have.
When my wife's grandmother died this past year, we handled things with our two kids (7 and 4 at the time) this way:
The girl (4) did not go (it was a long trip, and she had recently been sick). However, we told her what was being done, and gave her the very simple explanation (Her great-grandmother was a strong Christian). Now...I know she won't get a lot, and age 4 has no concept of the permanence of death...but we felt it important to explain.
My son (7) went with us to the funeral. We had him some things to play with, and we didn't expect him to hang out with the family in the FH (we hired a family friend to babysit in a nearby room, and he brought some toys). But, I did have him come with us briefly in the visitation room. And I gave him a choice about seeing the body (I explained that for some people, it helped them...but that I wouldn't make him do that). We then had a good talk about death, and life afterwards for a believer. He did attend the funeral (he's not an extremely emotional kid, and I knew he could "handle" it).
There are some cases in which I think it's wise to restrict kids...maybe a tragedy such as a murder...or the death of an unbeliever (depending on the age & sensitivity of the child)...or if the funeral/visitation will be chaotic or so emotional as to scare the kids.
But (and I'm speaking as a Christian and a minister here...I hope you know what I mean) if it is an "easy" funeral (please understand how I mean that...such as a death of an older saint who was suffering physically), it's a good place to have discussions.
But we should keep in mind:
1. The age & developmental stage of the child (such as younger kids not getting the permanence of death);
2. Sometimes children are more disturbed by the reactions of the grieving than they are the actual death/casket/viewing;
3. I think it important to teach the Scriptural truths of death...but to also stress to the child that people grieve differently, and as long as it's not against Scripture, that's perfectly fine. (One example: I told my son...some cry a lot, some don't; it doesn't mean one person loved Granny more than another).