The unfortunate fact of life, from your perspective, is that most mathematical questions are either intractable or known (or follow easily from known results). This is not to say that there aren't also a lot of interesting mathematical questions at the boundary between the two—otherwise doing mathematical research would be a hopeless enterprise—but it's not always so easy to locate that boundary.
Roughly speaking, there are two cases to consider. Case 1 is that there is specific well-known open problem or conjecture that you're trying to attack. In this case, there is a reasonably good chance that someone has written a survey paper that outlines the partial progress that has been made. If you're lucky, someone may also have described some of the fundamental barriers to further progress. For example, in the case of the $\mathsf{P} = \mathsf{NP}$ problem, there are the so-called "naturalization" and "relativization" (or "algebrization") barriers. If you have what you think is a new idea, then chances are it's somewhat similar to something that has already been tried. The survey paper can help direct you to the most relevant literature. Often you'll find that your question has already been answered, or that there is a known barrier which means that a simple bare-hands approach is highly unlikely to succeed. But if you're lucky, you'll find some work that is very close to what you're thinking, yet does not answer your questions. This is usually a promising sign that you've found the elusive boundary that I alluded to above. Of course it's tough to be sure; perhaps you'll prove something that you think is new but which an expert can see is a very easy consequence of known results, or which turns out to be not very interesting or fruitful. But to some extent, that is an occupational hazard of all research.
Case 2 is that you're not trying to solve a specific problem but are trying to develop some new theory. I have given my opinion about theory-building elsewhere on MO. Compared to Case 1, the advantage of Case 2 is that you have a somewhat better chance of coming up with something new. For example, if you're trying to generalize something, maybe nobody else has studied that generalization, not because it was intractable, but because they didn't see the point. One disadvantage is that it may be harder to figure out whether someone else has anticipated you, because there may not be a nice survey paper. Nevertheless, you should make a diligent effort to search for related work. If nothing else, the process will help you clarify in your mind how your ideas connect with other people's ideas. After all, if you're engaged in theory-building, clarifying your thoughts is the name of the game. Another disadvantage, especially when it comes to producing a research paper, is that if you're not making tangible progress toward answering a question that people care about, you may have trouble convincing people that you have made a meaningful contribution. But again, that is an occupational hazard of all theory-building.
As for your worry that some unforeseen obstacle causes everything to come crashing down, I actually think that this is not the main thing to worry about. It can happen; for example, I know someone who wasted a year of his Ph.D. program because he was relying on a published "theorem" that was known (but not to him or his advisor) to be false. It can also happen if you foolishly decide to try to prove the Riemann hypothesis without reading any literature. But if you have done some due diligence searching the literature, and if you take the sensible approach of starting with small things that you can definitely prove and working your way up from there, then you're not likely to bang your head into the "intractability" side of the boundary. The larger risk is usually that you'll produce something that turns out to be known, or not interesting. So if you're not sure what you're doing, you shouldn't spend six months working on something without getting some feedback (ideally from your advisor, if you're a student) about whether what you're doing is worthwhile. On the other hand, for a shorter amount of time, just following your nose can be worthwhile even if it "amounts to nothing" in terms of publishable results, because it will probably give you a good handle on the subject that will serve you well in the future.