There's no way to tell it's "no longer needed" though.
There's no central arbiter that decides whether a block is needed/valid or not.
Each node can decide for his own whether a block is need (e.g. part of longest chain) or valid (has to be validated anyways).
Nodes take the longest chain with the highest cumulative POW as the canonical blockchain.
The canonical blockchain could change if nodes receive another block that follows consensus rules but has a higher difficulty than the one they possess, even though the probability of a blockchain reorg 6 blocks deep is small, it's still theoretically possible.
For example the
March 2013 reorg was ~21 blocks deep.
Theoretically it still would not be necessary to store this block. In case of a reorganisation the block(s) can easily be broadcasted / received via the network.
Since nodes do choose the longest chain, why do they need to store an orphaned block from years ago ?
Do most clients (bitcoin core?) really store those orphaned blocks (especially from years ago)? If so, is there a specific reason why it has been decided to keep them ? Or are they just kept because there is no real reason to delete them?