The quality of a movie, most of the time, is never dictated by the amount of money it recieves at the box office. Your statement is just a flat out lie.
Why do people wish to simplifies things into such generalities?
The rule of thumb is good movies tend to make money more than bad movies,
BUT we need to factor in other important factors such as genres, demographics, release dates, and of course is it mainstream.
I thought Synecdoche, New York was a great film, yet it didn't make that much money, but two things it wasn't released in that many theaters and secondly it's narrative structure was far from the norm, unlike the far more popular Eternal Sunshine of Spotless Mind written by the same guy and followed a far more traditional story structure and had more traditional values, "Love Triumphs Over All".
Now let's move on to some more popular examples... Star Trek (2009) good movie went on to resuscitate the franchise and make over 200 million. Terminator Salvation, crap on a stick, went on to be a BO failure.
GI Joe not that great, but mediocre is going on to have a mediocre box office run.
Now we move to Transformers 2, sure it's god awful, but let's remember how much excitement the first one caused. The first movie was the ultimate popcorn flick and built up a helluva a fanbase hence why TF2 did good. But let's look at Fantastic Four the first did moderately well due to name recognition then the second one didn't do nearly as good.
And we could go on but for the most part good "mainstream" films do well, look at District 9.