Player-owned containers do not have their contents refreshed, hence the stuff you leave in it will stay there until you remove it yourself. Sometimes your item might survive a refresh and still be there when you look back. Next time you visit the barrel, there might only be apples in it.
The sword will most likely disappear after either 24 hours or 3 days (the standard pre-set refresh intervals). So say you stored a unique sword in a random barrel somewhere. Anything not on that list wont appear in the container when the contents are refreshed. The new contents are selected by the game from a predefined list.
No-one is stealing it, just the contents of most containers are refreshed every so often. If you leave stuff in a container you don't own, chances are it'll vanish after a few game-days.
Any container that doesn't belong to the player, IE is not in a player-owned house can be considered unsafe for storing gear.