Mandatory sentences came about because judges were letting criminals go free, or giving very light sentences. If someone thinks a mandatory sentence is too harsh, the elected legislature can change it. But if you leave it totally up to judges, many criminals will never set foot in jail.
Fair play but if that’s the case the answer is better judges through more scrutiny, accountability, etc.
Mandatory minimums put good and bad judges on equal (inferior) footing just as zero tolerance makes robots out of school administrators.