Layups are considered the most basic shot in the game, since they occur so close to the basket and are relatively easy to make. Shots only get harder the farther they are from the basket, so being in close range for a layup means it should be easier to make than a shot from deep, like a 3-pointer. A player shooting a layup also has the advantage of the backboard being able to help them get the ball into the basket, making it easier than a shot from a bad angle.
The most surefire way to make a layup is to use the backboard; that's what it is there for! Try to hit the top corner of the small box that surrounds the rim at an angle. With the perfect amount of power behind it, a layup that hits that spot should go in every time. The result will be 2 points for your team and hopefully a win!
So when should you attempt one? If you receive the ball close to the basket and have no one in front of you to block your shot, this would be the ideal time. The same goes for breakaways, an open lane when you are driving toward the basket, or backdoor passes. Layups can be smarter choices for these situations than dunks, since the player will not have to jump as high or maintain constant control of the ball in the air.