Blog post: Why I have a little C program to filter a $PATH (more or less) https://utcc.utoronto.ca/~cks/space/blog/unix/MyPATHFilteringProgram
tl;dr: because at one point I had a universal set of dotfiles where I listed every possible thing that could be in $PATH on every system I had an account on, and then filtered it down to only the (unique) directories that actually existed on the current system I was on.
It's a C program because in the old days this was faster than (limited) shell builtins.