there are a few ways really.
this is usually called finding product market fit or validation stages and each person will approach it slightly differently, but generally what (in my own opinion) works best is:
1) do something that doesn't scale to see if people need it. want to create a mental health app? start by talking to people in mental health-adjacent subreddits etc.
2) build something that solves your problem, then show it to others to see if they faced the same issue, this is usually more 'fun'