It's a watch pocket, originally for men who wore pocket watches and needed a protective place to store them. This little pocket, or the "fifth pocket" as some denim designers call it, appeared on the very first version of Levi's back in 1873.
According to the Levi Strauss website, it was “originally included as protection for pocket watches, thus the name.” It was worked into the design to protect cowboys' pocketwatches from falling out of their pants as they rode around on horses or worked on their ranches. Wearing it on a chain around their neck would cause it to easily tangle or break
Even though cowboys are still around, pocketwatches largely fell out of favor halfway through World War I, when soldiers needed a quick and accessible way to tell time. Digging around in their pockets for a watch just wasn’t practical, and the practice of wearing a wristwatch became a mainstay.
But with the use of wristwatches (and smart phones that tell more time than actual watches) the usefulness of mini-pocket has relatively become obsolete if not useless. But despite the functionality going down Levi Strauss & Co haven't altered their design, Levi's note that “this extra pouch has served many functions, evident in its many titles: frontier pocket, condom pocket, coin pocket, match pocket and ticket pocket, to name a few. Not only is the pocket extremely useful for holding tiny trinkets, it is also loved by denimheads for the faded and worn nature it takes on over time.”