Though the PlayStation 2 is considered the weaker piece of hardware from a technical standpoint, you certainly wouldn't know it from its sales numbers. It's currently the best-selling console of all time, with 160 million units sold between its release and discontinuation in 2013. Conversely, the GameCube only sold 21.7 million units between 2001 and 2007 before being phased out in favor of the Wii.
The story of the PlayStation 2's success is multifaceted, but much of it comes down to appealing to a broader audience. While the GameCube was seen more as a product for children, the PS2 garnered a much wider fanbase through adult-focused advertising (a particularly infamous one featured condoms in the shape of the console's controller buttons) and more mature-oriented games. Its broader application as a DVD player helped immensely too, especially since it was one of the most affordable DVD players at the time. The console's design was also much sleeker and understated than the GameCube (especially with its slim redesign), which helped it fit right in with a living room entertainment center.
Another big part of the PS2's appeal was its absolutely massive library of almost 4,500 titles. It attracted far better third-party support than the GameCube, largely due to the GCN's disc-size limitations and the PlayStation 2's boost in initial sales numbers from its earlier release date. The PS2 was home to several iconic exclusives; entries in the Ratchet and Clank, Jak, Metal Gear Solid and Persona series are just some of many that found a home there.
On top of that, the PS2's backward compatibility opened up an even bigger library. Though the GameCube has several masterpiece exclusives in its library, many of them appealed to existing Nintendo fans, and there was no option to play older titles. Meanwhile, the PS2 seemed to have something for everyone, ultimately giving it a huge edge.