As a big fan of Jack Vance I was recently reminded as I worked my way through Tales from the Dying Earth that magic in Jack’s world is essentially math and anyone with the brains and tenacity to study can learn magic. Here is a 5e optional rule for humans in any Vancian type setting.
For characters who are not magic-users but have a bonus from a high Intelligence score, the character can learn 1 wizard cantrip for each ability score bonus. For example, a character with an intelligence of 12 may learn 1 cantrip as you have an intelligence bonus of +1. You follow all the normal rules of the wizard class in how these cantrips are learned and used.