What the hell does Iron Man's Ark reactor do, anyway?

The function is nuclear fusion.

In the movie it was because Tony was shot and a lot of shrapnel was shot into his body, Ethan took out the rest of the shrapnel for him, and only some of the shrapnel that was very close to the heart wasn't there (you can't peel open the heart and take it out, right?), and so a miniature magnet was used in there to hold the shrapnel, which means that the base of that Ark Reactor is the magnet, and underneath that is the heart, and the wires are attached to the magnet.

I'm guessing you saw Pepper change Tony's EM there, and the reason Tony was convulsing wasn't because it was plugged into the heart but because of the short circuit, the magnet discharging and the fact that the magnet was spinning out of alignment causing the pulse meter to alert.

First of all the Ark reactor used by Tony Stark in "Iron Man" is a small nuclear reactor and a controlled fusion reactor at that.

The principle of this reactor is derived from the tokamak. A tokamak, is a toroidal vessel that utilizes magnetic confinement for controlled nuclear fusion. Its name Tokamak derives from annulus, vacuum chamber, magnet, coil. It was originally invented in the 1950s by Azimovici and others at the Kurchatov Institute in Moscow, USSR. In the center of the tokamak is a ring-shaped vacuum chamber with coils wound around the outside. When energized the inside of the tokamak generates a huge helical magnetic field that heats the plasma in it to very high temperatures for the purpose of fusion.