You are essentially trying to build a core component of a block explorer. Some related questions might be useful as background, like: How do block explorers actually work?
Note that even this brute-force approach of iterating all transaction recipients does not produce all account addresses, because of "internal transactions." See: How to get contract internal transactions
Even the subset of accounts you get by this iteration approach will be a very slow process. There's a lot of data to crunch through. But you can speed it up a bit by getting all the transactions in a block at once with:
block = w3.eth.getBlock(block_number, full_transactions=True)
for txn in block.transactions:
# add txn.to to the set of recipients
That will at least save you a bunch of round-trip calls to your node, because you only have to call your node once per block rather than once per transaction.