Many people (especially parents) ask a great many valid questions about this. Is it necessary? Will they get hurt? What's the point? Etc.
In order to understand how a technique works, one should experience it from both sides. We all know why you have to practice performing the technique, but sometimes we learn even more by having the technique done to us. Knowing how your opponent will feel/react/move when a technique is done to them is valuable in completely understanding how/when to use a technique.
Having techniques done to us (properly and controlled) also toughens up the body over time. There have been many martial arts documentaries showing how parts of the body karate-ka use to strike and block actually get more calcium over the years which leads to a sturdier martial artist.
Actually practicing the technique on another human being also helps students develop a sense of timing. This is one of the main reasons for sparring. Only a small fraction of the techniques in our style are legal in sparring, but we practice sparring regardless because it gives students a sense of timing that will make all their techniques more effective.
The very important question: Is it safe? Yes and no. The only reason I include the, "no" is because nothing is fool proof. There is always a chance of injury. But I say "yes" because in our dojo we minimize risk as often as possible. We wear plenty of protective padding so that we can train hard every week. If we did sparring without gear, we would only be able to practice it a few time per year. I've been teaching karate for over eight years. I can count the number of injuries worse than a bruise on one hand.