The term trivial comes from mathematics, where it is essentially a technical term with a relatively precise meaning.
The etymology of the term is said to have started with the way university studies were organised in the Middle Ages.
trivium (taught first):
So we can assume that trivial originally referred to what didn't have to be repeated in the study of mathematics (arithmetic and geometry), music or astronomy because it was already clear from what students had learned in the trivium.
The modern sense in which mathematicians use the term trivial is still pretty close to this (presumed) original one, though in some ways it has been generalised and extended to different contexts. I will try to illustrate this with non-mathematical examples that capture the essence of the term:
The question whether a platypus or a cangaroo is a mammal is a non-trivial one. This is not the kind of thing that was taught in the trivium or that can be resolved by simple logical thinking. It depends on deeper knowledge of these animals and the precise choice of words in the definition of mammals. The question whether a cow is a mammal is arguably trivial. (Remember I said above that mathematicians use the word in a relatively precise way. This is nothing unusual. Most words are a bit fuzzy like that.) The question whether all unicorns are mammals (note the formulation, which matters in this case) is trivial in the sense that we can assume it to be general knowledge that unicorns don't exist. So the claim follows by pure logic without any required further knowledge of unicorns or mammals. It is equally true, and equally trivial, that all unicorns are insects and that all pink dragons are pregnant.
A derived usage is to call a mathematical object trivial if it is as simple as possible, provided this means it's totally boring. Some examples of this should be generally accessible. (1) For example the set of all unicorns is empty, and we could call the empty set the trivial set. (2) Every group must contain at least a unit element, often called 1 or e. So there is no such thing as an empty group. But if 1 is the only element of a group, the group is called trivial because it's as simple as it could possibly be.
The term non-trivial also comes from mathematics. As many negated notions do, it has two related meanings. The more technical one is just the negation of trivial. In this sense, calling a question non-trivial is just a short way of saying it is not trivial. Also (1) a non-trivial set is a non-empty one, (2) a non-trivial group is one with more than one element (i.e. with other elements besides 1).
The other meaning of non-trivial could be described as far from trivial. This usage probably started as an understatement, and it's what people usually mean when they call a problem non-trivial. Though not defined precisely, it often means roughly that a mathematician of average skill working in a different field wouldn't be able to solve the problem in a short time just by examining the definitions.
The precise interpretation of non-trivial depends on context just like the interpretations of similar words such as non-technical or non-violent do.