It was because of a woman named Bertha Kinsky. She was a pacifist and a free-thinker (which means anti-religious). He fell in love with her, and they married, but she left him. He was wealthy, but not intellectually respected. He inherited his father's industrial business, which was, horror of horrors, an arms manufacturer. He was not a college graduate, but he learned chemistry anyway and developed dynamite, and became one of the wealthiest men in the world. He went on to write poems and anti-Christian plays, but they never respected him. She never really respected him. Alfred Nobel had money, but not status.
Then came an erroneous news report that he had died. Nobel had an experience that few ever get: he read his own obituary. It was harsh, referring to him as a merchant of death. Didn't they know what dynamite was mainly used for? Roads, bridges, tunnels. Dynamite brought people together when giant mountains of stone kept them apart. But that never was enough for the intellectuals, the journal people, Bertha's kind of people. Alfred Nobel, who had used his mind to create something of much greater value than all of the free-thinking playwrights and revolutionary poets, was unhappy. He wanted them to love him; he wanted her to love him. He wanted a glowing obituary.
His beloved Bertha, with whom he still corresponded long after their divorce, had an idea: Alfred could use his money to create a prize. People who work for peace, like Bertha's friends, would get money and acclaim for their efforts.
So he gave much of his fortune to the creation of a prize that would give money to exactly the type of people who had held him at arms length. He tried to buy their love. He tried to buy her love. He gave the authority to confer the prize to the government of Norway (which at the time was under the same crown as Sweden).
He got his glowing obituary. He didn't get the girl. The world got dynamite and was crisscrossed with train tracks and roads and bridges. Mountains became temporary impediments, rather than permanent dividers. The backs of millions of laborers were saved by this useful chemical compound. And yes, sometimes dynamite was used as a weapon.