Were the physical constants chosen randomly by Nature?

No-one knows the answer to this, so the best I can do is describe some of the ideas. Bear in mind this is all speculative so take it with a pinch of salt.

In our existing tried and tested theories the fundamental constants are put in by hand and there is no mechanism for them to vary. However the idea that constants might be variable goes back as far as Dirac.

Many experiments have looked for variation in the fundamental constants, but so far without success. Examples include the Oklo natural reactor and many astronomical studies looking for changes in the fine structure constant.

The most concrete proposal for variable fundamental constants comes from string theory. This requires six of the spatial dimensions to be compatified so we don't see them. This compactification can occur in many different ways, at least $10^{500}$ according to the landscape idea, and each different compactification will result in different fundamental constants. Whether this really describes our universe is currently a highly contentious issue.