Initial disclaimer: no no one really knows, as the process predates any written record.
Now onto the educated speculation:
We're used to the idea of copper ore and copper mines, but in ancient times, copper was available in surface deposits. Not as copper-bearing ore, but just copper, the orange metal we're all familiar with. This native copper was pretty great. People could pick it up and bang on it with a rock until it was a useful (though very brittle) shape. Not long after, they probably discovered that copper was easier to shape the more they heated it up. Even better, the heat-shaped copper was less brittle. The technical name for this process is annealing.
Annealing isn't smelting, but it's the first step.
As annealing made better tools than the "banging on it with a rock" technique, people had an incentive to play around with fire and every caveman knows a fire grows brighter when someone blows on it. Blow on the fire through a reed, maybe make a crude bellows. As their technique improved, some lucky tinkerer (or many different tinkerers) discovered that the melting point of native copper isn't much higher than, say, a really ambitious campfire and, once it was melted, copper could be poured into a mold, eliminating the need to bang on it with a rock entirely. Awesome!
Once the surface copper wasn't able to meet demand anymore, people started digging into the ground to follow the veins. That put them in contact with copper-rich ores surrounding the native copper.
So now we have hot fires, thanks to the tinkerers and we have the ore, thanks to the diggers. All that's required is for someone to put a green rock into a hot enough fire. There's no way to know who the first person to smelt an ore would have been, but we do know that copper smelting appeared independently all over the world, so it can't have been that difficult, once the incentives were in place.
Unfortunately, the single-element metals available to ancient people weren't all that useful. Copper makes a decent razor or mirror, but that's about it. Gold is shiny, but completely useless as a tool. Lead is more common than gold, but it's soft and dull, so it makes a terrible axe. Lead had to wait until Rome needed pipes and rain gutters before it was useful.
The really big innovation was bronze, which required copper and tin (or arsenic) and tin is really pretty rare and what tin deposits there are were tended to be in far-flung places (Northern Europe, Asia), so people had figure out how to smelt various ores, then had to so some more tinkering, then they had to set up elaborate trade routes to get copper and tin into the same fire at the same time, but those who could make bronze won empires.
*: It should also be mentioned that gold played a role here. It's too soft to be useful as a tool, but it has a lower melting point and it's pretty.
Hi, questions about ancient humans would be worth x-posting to our sister sub /r/AskAnthropology. Meanwhile, you may be interested in a few previous comments here: