It sounds like what you're finding is dungeons with loot, which are a part of the mapgen. Those were meant to add some spice to the game, and possibly tease players with some more advanced content to get them interested in trying to make those things themselves. The closest thing that the game has to official "lore" for them is that they're the remnants of a past civilization that once developed on this world, but apparently had to flee suddenly, leaving a lot of their stuff behind in disarray. Much is still left to the player's imagination.
While the loot itself is randomly generated, the actual rarity tables for loot were based on a sampling of items stored by players on the NodeCore Community server ... so in a way, that "past civilization" could be an alternate history for the server.