Where do the elements come from? Nuclear astrophysics proposes several origins, depending on the element: the Big Bang, dying and exploding stars, and cosmic rays.

A hundred years ago we didn’t have a good idea of where the elements came from. A couple of scientific papers, from 1948 and 1957, changed all that.
First, the Alpher–Bethe–Gamow paper “The Origin of Chemical Elements” from 1948 introduced the idea that elements were formed very soon after the Big Bang. Conditions were hot enough, pressure was heavy enough, and the proportions of subatomic particles just right for light elements to form. This would have happened between 10 seconds and 20 minutes after the Big Bang, and produced mostly hydrogen and helium isotopes.
Funny story about that paper: it was actually written by Alpher and Gamow, the latter at the time supervising the former’s PhD. But Gamow couldn’t resist a pun, and decided to add the name of another physicist (Bethe) so that the author list sounded like the first three Greek letters: alpha, beta, and gamma. Gamow thought it was hilarious, Alpher was very unhappy with the joke. Honestly, I would have been unhappy too!
Anyway, the αβγ paper was correct that the universe’s supply of hydrogen and helium formed right after the Big Bang, but it was incorrect in thinking that the other elements appeared at this time too. Another landmark paper – published in 1957 by Margaret Burbidge, Geoffrey Burbidge, William Fowler, and Fred Hoyle – suggested some mechanisms by which heavier elements could be formed.
This paper has a funny name too – it’s known as B2FH (after its four authors, abbreviating their initials like a chemical compound). It united the observational astronomical data from Margaret and Geoffrey Burbidge with lab experiments by Fowler and theories by Hoyle to demonstrate that the environments inside dying stars were just right to produce heavier elements, long after the Big Bang had wrapped up.
Subsequent work has refined the ways in which elements can form inside stars and supernovae. It added a new method, too: cosmic rays. I’ve written about those rays before, protons, electrons and other particles shooting through the universe and occasionally disrupting elections in Belgium. Well sometimes when those rays hit other elements they form new elements. It’s a process known as cosmic ray spallation and almost all of the universe’s supply of beryllium and boron come from that rare event.