I don’t think this is correct. You are assuming the force needed to roll a ball up a ramp is the same as the force needed to stop a ball dropping vertically, and that patently isn’t so.
We’ll ignore friction for the moment, and let’s imagine a ramp the lowest end of which we shall call point A. Your magnet you fix at a point being distance D up the ramp. You have an iron ball upon which gravity exerts a vertical force W. The magnet exerts an attractive force on the ball, which we shall call M. The force required to cause the ball to roll up the ramp we will call R.
I think you will agree that due to the mechanical advantage offered by the ramp (at any angle other than vertical) R must be less than W.
You set your ramp angle such that at distance D the force M is only just greater than R so that the ball will (only just) roll up the ramp. Such an angle must exist, since as the ramp angle decreases from vertical toward horizontal, the component of force W that the magnet has to overcome to cause the ball to go up the ramp reduces towards zero.
Now, as the ball goes up the ramp force M will increase as you say. At the point where M approaches but does not exceed W, you cut your drop slot. When the ball reaches the slot it will fall because now that the ball is exposed to gravity without the ramp R is no longer relevant, and M can no longer use the mechanical advantage of the ramp to assist it in overcoming W, and so W will overcome M and the ball will fall.
You could then have a return ramp leading away from the slot, down and then out back to point A. Obviously for the return ramp to end up back at point A, and given that the slot must allow the ball to fall vertically initially, to get away from the magnet the latter parts of the return ramp would have to be a shallower angle than the up ramp.
The ball will have gained potential energy by being lifted up by the magnet. The problem however is that as the ball moves down and out via the slot and the return ramp it will be fighting the pull of the magnet. And the work required to fight that fight will precisely equal the potential energy gained by going up the ramp.
In a totally frictionless environment, the ball might go round and round forever, but in reality it would fall down the slot but then slow and not make it back out to Point A because, due to friction losses, the speed gained by falling down the slot would not be enough to overcome the pull of the magnet as the ball rolled out on the return ramp. And if you made the ball do any work (such as pushing a lever) then all the more so.
In essence, a simpler model of the same thing is this: anchor a mega magnet on a perfectly flat frictionless plane. Around the mega magnet, place a perfectly elastic bumper. Put an iron ball on the plane within the magnetic field. It will roll in, and hit the bumper. Despite the (necessarily) stronger magnetic field near the bumper, the kinetic energy of the rolling ball will permit it to bounce away from the magnet (just as the potential energy of the ball up the ramp permits it to get away from the magnet). The iron ball will just bounce out a way, then back in to the bumper endlessly.