It's a bit complex for a comment, but the TLDR is:
* funds in transit (called "positive float") are held in the banks account, and can be used by the bank to earn interest
* liquidity management - there are a bunch of considerations here, but the longer settlement periods enable banks to do "deferred net settlements" (just paying each other the difference between all transactions in a batched way) and also helps balance sheets in other ways, making it easier to meet reserve requirements, smoothing out intra-day liquidity, etc
The delay also means systems have more time to catch fraudulent transactions, and to block them before they happen.