When accomplyshing a task, it is motivating to have purpose, a goal, a reason why you are doing something. For example, the productivity of the scientists working at Los Alamos with Feynman, building the atomic bomb, increased considerably when they were told what they were doing there. That is, they understood the importance of the task at hand. They had to be quick to defeat the enemy and save their country.
Imagine when you were in High School if teachers would have given you a reason why you were doing all those tedious homeworks and drills, and memorizing stuff.
Take as an example Udacity University. When you are learning “Intro to computer science”, the goal is build a search engine. All pieces of the puzzle come along together as you go by in the course, towards that goal. That’s motivating.
If you are an educator, don’t forget to explain your pupils why they are learning what you are teaching.