I was wondering whether it is permissible to invest into index funds/ETFs? Like the S&P 500 for example

As long as the fund does not include haram companies (like a company that sells alcohol) then it’s ok