Software engineering is mainly knowledge work. This means the majority of work consists not of building stuff, but acquiring and organising knowledge. I've read somewhere that about 50% of the job is gathering information.
When a person leaves after having spent two years at a company, it might look like you get to keep everything they've been working on, but this is far from true. If the 50% assumption is correct, a person leaving after two years means you throw a full year of work into the dump. This is a huge cost, but it's hidden.