The idea that spaceflight should be given more support because it is particularly educationally inspirational is a frequent topic in space advocacy, both in popular science and peer-reviewed scientific and space policy literature.
Improved interest in STEM fields (as shown by STEM enrollments) or increased scientific knowledge among the general population may be evidence of such motivation.
For the time being, I'll concede that achieving both of these objectives would be beneficial.
I am particularly uninterested in debating the value of increasing general public scientific literacy; however, I grant that it is debatable whether society (at least, American society) is currently in need of more individuals with STEM degrees, as enrollments in engineering and computer science, in particular, have shown strong growth over the last 30 years (but perhaps the complaint is that enrollments in engineering and computer science have shown strong growth over the last 30 years).
I'm not going to argue that any of these jobs is impossible to do. What I'll argue is that there's no conclusive evidence that spaceflight is a good source of either kind of inspiration.
We have no related duty to fund spaceflight since it is not an effective means of fulfilling the commitment (if there is one) to inspire interest in science.
~ Jai Krishna Ponnappan
You may also want to read more about Space Exploration, Space Missions and Systems here.