The A-320 was a runaway success which threatened to shut Boeing out of that segment. Boeing needed to do something, and fast. Hence the 737-MAX as a stop-gap until they could come up with a better competitor.
Yes, the A-380 (different segment) did poorly. Boeing actually had a nice thing going for them with the 787.