I've gone through this with @Duke of Marmalade who is an actuary and understands these things from his insurance company background. He very clearly explained how Index Trackers operate.
If I set up an Index Tracker, I just buy shares in the index in the proportions they make up the Index. Those share values just rise and fall with the Index. I don't do much except likely reinvest dividends and maybe deal at some point with a company being taken over or taken private.
Far be it from me to disagree with His Grace, but my unworthy, even pathetic, understanding is that this is not, in fact, how tracker funds are actually operated.
There may be many stocks in the index that are not traded in the numbers that would be necessary for all the index-tracking funds to buy them in the quantities required. (Obviously, this depends on exactly which index you are tracking — it's feasible to hold every stock in the FTSE 100, but not every stock in the FTSE All-Share. And it's generally not feasible with global indices, small-cap indices, etc.)
And there's another tier of stocks that could be purchased in the required numbers, but the amount of trading involved, relative to the volume of trading these stocks normally attract, would be such as to affect the price of the stocks, which would defeat the whole point of the exercise — the index funds would be
setting the index, not tracking it.
Finally, remember that the index takes no account of transaction costs. So the more you attempt to replicate the index by entering into stock transactions, the more your performance net of costs will inevitably underperform the index. Some stock transactions are of course inevitable, but it's often cheaper to track a stock through derivative products than it to hold the stock, so the rational course is to do that.
Even where buying every stock in the index is feasible, it's usually the most expensive way of tracking the index. Take the FTSE 100 index — it is possible to track that by buying all 100 stocks in the index. But stock prices change all the time, so every quarter the index composition is reviewed; a few stocks drop out of the index. because they are no longer among the top hundred companies by market capitalisation, to be replaced by stocks that have entered the top 100. If you're tracking the index by holding the constitutent stocks, you have to sell your
entire holding of the "relegated" stocks and buy holdings of the "promoted" stocks. And, in another quarter, you have to sell your holdings of more relegated stocks, and buy the newly-promoted stocks — quite possibly, buying back holdings that you dumped just three months ago. In a typical year, there are between 8 and 20 constituent changes in the FTSE 100 index. That costs the index nothing, but if you have to replicate that by buying and selling the stocks concerned in the appropriate volumes, it will cost you a lot. And of course you'll be realising losses or gains every time.
Index-tracking managers, generally speaking, do in fact engage in stock selection — as in, they decide which stocks in the index they will purchase and which they will not. But they do not to this by attempting to project which stocks will outperform; they aim to identify a representative subset of the index stocks, chosen to match the index’s key risk factors (sector weights, credit quality, regional exposure, size, style, etc), if possible steering clear of stocks that are at greater risk of dropping out of the index. And then they refine that with a range of synthetic or derivative instruments intended to hedge against the risk that the performance of their chosen stocks will diverge from the performance of the index. The balance between actually holding stocks and doing devilishly clever things with derivatives and synthetics will vary both from index to index and, for a given index, from manager to manager.
So, passive managers are entering into stock purchases and sales, perhaps more often that you suppose, and they are entering into other more sophisticated transactions involving various derivative instruments which also involve taxable events when e.g. options are exercised or released, futures contracts mature, etc..
So both passively and actively managed funds do realise gains and losses, and they do receive income.