It completely has to do with several factors... it's not just random:
- If you have a latent mental disorder
- What's going on with your mental state at the time ("set")
- The environment you're in ("setting")
- How you deal with the come-up stage (the beginning before the peak)
If you have a latent mental disorder, then psychedelics like LSD can trigger it to emerge. It most likely would have happened anyway, but psychedelics have been found to be a serious trigger. I have no idea what this would be like. If you have a family history of schizophrenia or any other serious mental disorders I would stay away from psychedelics and stimulants especially, and drugs in general.
But aside from that special and rare case, it really depends about 50% on what's going on in your head... if you've ever heard the term "set and setting", that's the "set". You need to analyze how your life is at the moment. Do you have anything that's causing you conflict? An example could be that you're feeling bad because you're feeling like you do too many drugs. Or that you're lying to someone about your use of them, or about your use of the acid you're thinking of taking. Or maybe you've been feeling depressed because you feel like your life has been going nowhere because you need to improve your situation and you've been lazy. Those would all be examples of situations to avoid with psychedelics as they will be likely to bring on a "bad trip" if you don't know how to deal with it. (Psychedelics can be used as tools for helping you to investigate some kinds of internal issues but your first time is not the time for that).
The other 50% of your consideration is the environment you choose to put yourself in when you trip, your "setting". This is probably the #1 reason why people have bad trips, especially kids. You REALLY need to make sure you have a good setting. What I mean by that is that you need to have a controlled environment (and kids tend to have a hard time getting this... at your parents' house when they're home or going to be home is not an option. I once learned that the hard way). Take it alone or with a few close friends, in a place where you will not have any chance of being disturbed by anyone who is not you or someone else you trust and who knows about the trip beforehand. Turn off your phones so you don't get calls because what seems like a good or appropriate thing to do at the time may, in fact, not be, despite
really seeming like a good idea at the time.

If you do it outside (which is
highly recommend if at all possible, as nature always makes trips feel more magical and friendly to me), make sure you're not going to get the police called on you, or in other words, do it away from other people where other people are not likely to come and where they would have no problem with you being there if they did come. Basically, plan your trip out in advance and make sure you wait for the right time when all of your plans can come to fruition properly.
Finally, the
other 50%

of what goes into it is the unknown factor, which you can't really prepare for. It's the come-up stage, the stage at which you're transitioning from a sober mind to a psychedelic mind. LSD tends to be a little easier than some for this, but in general, coming up on a psychedelic can be rough. It isn't always, but it can be, and a big reason for a lot of people having negative and unpleasant experiences is because they can't handle this, and the main reason they can't handle it is because they don't expect it. You might start to feel really uncomfortable and intense... this feel can feel quite clastrophobic so you start to get anxious... thoughts start to creep in like "what the fuck did I eat this for? I wish I could take it back! Man, I wonder how long this will last? Oh man, WHY did I DO this?? Did I take too much? Am I ODing? Am I going to go crazy forever??"... and so forth. This can easily give way to panic. What you need to do is make sure to keep mindful that it is just a drug. If you hang on and keep yourself from panicking, once you cross over into the peak, I promise you, all of that will fall away and you'll see what everyone's talking about. But if you panic, you might get stuck in a loop of self-doubt and anxiety and never really trip and just have a crappy and/or terrifying time. THIS is the main reason why the mental set you have going in is so important, because during the come-up your ego is going to throw about every insecurity and issue you've got at you and if there's something serious that you are not being honest with yourself about, it might be too much to handle. Think of psychedelics as the opposite of most drugs: the hangover comes first, but if you ride it out you'll be left feeling amazing for days or weeks. It's a really shitty hangover, but it will be over soon enough and then you're on to what you were looking for. And then of course you could have an easy come-up full of giggles. But you need to be prepared mentally for a rough come-up.
As for being alone or with people, I personally really enjoy tripping alone but I don't recommend it for your first time because you don't know how it will affect you. It's best to be with a friend or two, preferably with a "sitter", a sober or at least non-tripping person who can sort of watch over you but be able to be cool with the situation, someone who's tripped before if at all possible. It is not a good idea at all to trip with people you don't really know and REALLY not people you don't trust, as you never know what can come out of people on psychedelics and you'll be really sensitive to vibes and emotions from people. A close friend or two is the best, a total group of 2 or 3 including yourself, in my opinion.
Finally, you need to realize that a "bad trip", aside from a few rare mental disorder-related instances, is just an experience. You are the one who would be making it "bad". Let's say you ignore my advice about "set" and you go into the trip trying to hide it from your parents, or your girlfriend, or something like that. Well then you might end up feeling 6 hours of abject misery while your subconsciousness pummels you with all of your faults, rueing the day you ever touched LSD, swearing off all drugs forever if only you could feel normal again, fearing that you never will. Well, you could choose to see this as a *gasp*
"BAD TRIP"... try to suppress the experience, forget it ever happened, block it, shove it down... and then it will come back up, like anything else you try to suppress inside, and create problems for you.
Or, after you come down, you could realize that in taking the drug you were taught a valuable lesson in being honest with yourself and the people you love and that it's YOUR fault for being in this situation, and you can take it as a lesson and walk away a happier person knowing what you need to change about yourself.
Or, perhaps you had some sort of deeply significant experience that shatters your foundations of what you believe and how you see the world and existence. This is a real possibility, and it is why many people use psychedelics at all, and why they are such serious and powerful tools. In this case, some people find confusion and fear and feeling like they are lost. But this, too, is all in how you see it. You could choose to just take experiences as they come to you and allow those experiences to shape the way you believe about the way things are, and find great comfort and joy in what you've seen, as so many have, or you could allow previous ingrained ideas to push all of this away, suppress it down deep inside, and like anything you suppress, it will eat away inside of you.
And FINALLY, please realize that low dosages of psychedelics are usually going to be disappointing. A lot of LSD these days is distributed quite weakly per "hit", so try to get a feel for how strong it is (and a dealer saying "it's double-dipped or it's bomb" or something isn't a good indicator), and try to dose a full dose. I guess what I'm saying is that a lot of LSD these days, at least in the US, is too weak at 1 hit to make you really trip. But 2 would be a good place to start. And then, whatever you get could be quite good at 1 hit. If you know anyone you can trust who's had the same stuff that could be a good indicator. And sometimes you just have to doss the dice when you're dealing with illegal drugs.
