This page of the Valheim guide contains information about the stealth mechanics. Among other things, you will learn how to avoid detection.
Stealth will allow you to avoid combat. This is especially important when you are low on life points and a potential fight may end in your death. Each enemy is sensitive to sound and has a specified field of view. So avoiding confrontation is possible.
The moment an enemy appears in the vicinity, press the button assigned to entering silent movement mode. At the same time, a special visibility meter will appear - the higher it is, the more exposed you are. The meter value depends on the level of stealth skill and whether your character is in a lighted area.
However, you must keep in mind that you cannot sneak all the time. Stealth drains stamina, which regenerates only when you stay still. When it runs out, the character will start moving in standard mode.
Sneaking is also affected by the armor you wear - the troll set adds 25% to that particular stat.