How does the IPFS decide how many copies of a certain file to maintain?
It doesn’t, if people holds copy, they hold copy, but IPFS never takes any initiative.
A file will be stored in multiple locations, if multiple people (or one guy managing multiple nodes) pins the file, or if someone who downloaded your file, has the reproviding service enabled (it’s the default).
How does i decide where to maintain them?
If you are using IPFS alone, just pin them on multiple nodes you own.
You can use
ipfs-cluster to make that task way more simpler and manage multiple nodes as one.
Under what conditions would that file be completely removed from the IPFS?
If every nodes hosting a file either goes offline or run the garbage collection and remove that file from their local cache.
Note an offline node might spin back up, or someone else can add the same file back, so you can never truely be certain that a file will be erased.
You need to think that IPFS may just never forget and there is nothing you can do about it.