If the ice maker if refilling quickly after making a batch of ice, then the problem will likely be in the valve in the door dispenser or some kind of blockage in the line leading there.
The first easy fix that comes to mind is an ice buildup, since I've seen that wreck havoc on in door dispensers. You can try turning off the fridge and taking a hair dryer to the dispenser from each side to defrost any buildup, and then do your best to dry out anything that drips.
Beyond that, this will probably require taking the dispenser apart, possibly replacing the valve, or it may be as easy as cleaning the spout.
As mentioned by @Steven. You'll want to get yourself an ammeter, and figure out how much current the appliance is drawing. While shopping for the meter, you'll want to look for a "Peak Hold" feature (though it might go by other names depending on the manufacturer). This feature will allow the meter to retain the highest measured value. That way you don't have to monitor the meter.
Remember when using the meter, you have to clamp it only around one of the circuit wires. If you clamp it around the cord; for example, you'll always get a reading of 0. The best way to do this, is to clamp the meter around the ungrounded (hot) conductor in the panel where it connects to the breaker.
Circuit breakers include overload protection, which is also known as thermal protection. This is typically a bimetallic strip, that pulls the contacts open if it gets too hot. This type of protection is time delayed, since the device has to physically heat up. If the current through the breaker is really high (but less than what trips the magnetic protection), the device will heat up quicker and react more quickly. In your case, however, it's more likely that the current is just high enough to cause the breaker to slowly overheat. This would explain why letting it cool down (waiting), would allow it to run longer once reset.
Your intuition could also be correct, and a loose connection could be exacerbated by the heating due to high current draw.
In either case, an ammeter will be a useful tool to start diagnosing this issue.
NOTES:
- If the breaker is a GFCI breaker, the sanitize cycle could simply be leaking too much current.
- If the breaker is an AFCI breaker, the sanitize cycle may be doing something strange that the AFCI is picking up.
- Thermal protection in circuit breakers can be affected by the ambient temperature, and the temperature inside the panel. So if the panel is in a really hot location, it could trip before it typically would/should.
Update:
Now that it's clear that the circuit is protected by an arc-fault circuit interrupter (AFCI) circuit breaker, I'd like to change my answer. While an ammeter is useful, and testing the max. current draw might be useful. I suspect that the machine is doing something during the sanitize cycle, that the AFCI doesn't like.
Best Answer
The path of least resistance.
When the ground is removed, the current is forced to go through the compressor, and fridge works.
When you replace the ground, there is a path from hot to ground, that avoids the compressor.
Possibly a problem in the receptacle where the hot wire will short when the ground pin is inserted, but unlikely. If you want to test for this, plug in something else with a ground pin, wiggle the cord, and if it works, the fridge is the problem.
The wire should be loose - long and had too much room to move around and got pinched, or it should be really tight, because it did not have enough room to move.
There does not have to be much damage to the insulation for this to happen, but running your fingers along the wires should be enough to find it.
Best of luck to you