Flushing the dbcache is the mechanism by which the database on disk is brought in sync with the database in memory. Since the UTXO set constantly changes, it's more performant to cache the most recent changes in memory rather than writing everything out to disk immediately as disk I/O can be pretty slow.
Because entries contained in the dbcache are not always on disk, an event that kills bitcoind before the flush can occur (such as sudden power loss) results in those UTXO set changes being lost. But this is not catastrophic as long as we still have the blocks. We can just load up the chainstate with the most recent data, and go through those blocks again to update the chainstate.
With pruning, we are going to be deleting blocks. This introduces a situation where we have UTXO set changes in the dbcache but not on disk and the blocks originating those changes have been removed. If bitcoind were to be killed at this time, we would have no way of recovering the changes without re-downloading the blocks. By flushing the dbcache before removing the blk*.dat and undo*.dat files, we can ensure that the UTXO set on disk is up to date before the files are pruned.