Toenails primarily serve as a protective barrier for your toes. They act as a shield against injury, similar to how Captain America's shield protects him. Imagine stubbing your toe on a piece of furniture; your toenail helps absorb the force of the impact.
Beyond protection, toenails also contribute to proprioception, your body's sense of movement, action, and location. This means they help you understand where your toes are in space and how they're moving.
Although not as prominent as fingernails, toenails offer a degree of support during walking and running, acting as shock absorbers to distribute pressure across your toes.
Toenails have evolved in primates, including humans, as a result of their ability to help with various tasks, such as removing ticks and manipulating objects.