Index funds work because weve been in a 20 year long bull market. If the market goes sideways for a decade, or down for a decade then active investing is alot more profitable.
For example, if you bought near the top in 2000, you were still underwater a decade later.