Why wasn't the 737 MAX's landing gear lengthened enough to mount the engines under the wings, rather than in front of them? The reason Boeing originally added the MCAS to the 737 MAX was to compensate for a slight pitch-up moment generated by the engine nacelles at very high angles of attack.  This pitch-up moment occurred because the LEAP engine used on the MAX series is larger and longer than the CFM56 used on the 737 Classic/NG, so Boeing mounted the new engines further forward and higher up to fit them on the plane; the larger, forwarder nacelles added more planform area to the front part of the aircraft, causing the MAX's center of lift at high attack angles to be slightly forwarder than on the Classic or NG, causing the MAX to pitch up slightly more at high attack angles.

However, the reason the Classic and NG have their engines mounted in front of the wing is that the 737 originally used the much slimmer JT8D engine, allowing it to use a very short landing gear to make it sit lower on the ground and ease the process of loading baggage and other cargo by hand.  When the Classics came along, Boeing decided to keep the 737-100/-200-length landing gear, which forced them to use a smaller-fan variant of the CFM56, move all the engine accessories from the bottom to the sides, and mount it in front of the wing (instead of directly below it) in order to give the new, larger engine sufficient ground clearance; with the NGs, which use a CFM56 variant that is essentially the same size as that used on the Classics (with a diameter all of one inch greater), they simply kept the same nacelle, pylon, and landing gear designs as those used on the Classics.

The MAX, in contrast, has a longer landing gear than all other 737s (handloading of baggage not really being that much of a thing anymore at most 737-served airports); given that they were giving the MAX a longer landing gear anyway, why not make it long enough to let the engines fit under the wings and finally eliminate the engine-mounting kludge inherited all the way from the 737-300?
The main gear sits between the wings and retracts inwards, such that the wheels will rest in the lower fuselage. Lengthening the main gear would either require to shift the gear attachment points outward or to retract one leg a bit forward and the other a bit backwards, such that both wheels will sit behind each other instead of side-by-side, as they do now - see below (source).



Shifting the gear attachment points out is clearly feasible but results in a major wing redesign. That would cost money so Boeing management decided that a software fix would be the better solution.

Placing the wheels in tandem would equally be a major and costly modification. A lot of systems would need to be relocated and all modifications would require testing. Boeing management cleary did not want to pursue this option.

Another quick fix is shortening the gear upon retraction. Decompressing the oleo strut in order to shorten the gear upon retraction is already standard in many fighter jets. Another solution is to add another hinge such that the gear leg will fold inside the gear bay. Such a solution was used on the Grumman F-8F Bearcat and is pictured below (source).



From what I understand, this particular solution was applied to the longest 737 version to allow enough tail clearance for rotation, but added weight and complexity. Of course it could be applied to the rest of the 737 MAX fleet as well, but again Boeing management tried to save money and weight by implementing a software-only solution.

But the engine location would be fine if a larger horizontal tail would be added, increasing stability at high angle of attack and making a quick software fix unnecessary. Again, this would add cost and weight and make the aircraft less competitive.