The virus has to enter a living cell to infect you because the virus itself is not “alive”. The virus hijacks the cells function and changes it to replicate more copies of the virus, which then get dispersed when the cell dies.
What happens then is a statistical battle between the virus and your immune system. Whoever can produce more soldiers wins. Your immune system has to learn to recognize and destroy the virus critters. Vaccines teach it.
Do not rely on my explanation, it’s all the physiologists could teach me when I worked with them.
Closest simile, it’s like the battle of britain in your body with the germans being the virus.