Start with the question
Before you pick a number, ask what the photo needs to do. Should the subject stand out from a soft background? Should everything from the foreground to the horizon be sharp? Is the light so low that you need as much of it as you can get? The answer narrows the choice quickly.
There is no single correct aperture. The right one depends on the subject, the scene and the look you want.
To separate a subject from the background
A wider aperture, such as f/1.8, f/2.8 or f/4, gives a thinner band of sharp focus. That helps a subject stand out, especially a person or an animal that is close to the camera. The background becomes softer, and bright distractions often become less busy.
Distance matters too. A subject that is far from the background will show more blur than one standing right in front of a wall, even at the same aperture. If you want more background blur, you can often move the subject away from what is behind them.
To keep a scene sharp
For landscapes, group photos and architecture, a narrower aperture keeps more of the scene in focus. Values from about f/8 to f/11 are a common starting point for many scenes on many cameras, and you can adjust from there after checking the result.
Avoid going straight to the smallest setting. At very narrow apertures, light bends at the edge of the opening and fine detail can soften. Many photographers find it better to choose a middle value and check the image at full size.
When the light is low
In dim light, the widest aperture your lens offers gives you the most light to work with. That lets you keep the shutter speed high enough to avoid blur from hand movement, or keep the ISO lower to limit noise. The trade-off is a thinner focus zone, so the subject needs to be carefully focused.
When the subject is moving
Aperture alone does not decide whether a moving subject looks sharp. Shutter speed matters more for freezing motion, so set a shutter speed fast enough for the subject first, then choose an aperture that gives the light and depth of field you need. If the shutter speed is fixed, the aperture and ISO will need to balance it.
Distance and focal length also count
The same aperture can produce different results depending on focal length and how close you are to the subject. A longer lens at the same aperture usually gives a thinner band of focus. Standing closer also makes the focus zone thinner. If you want more depth of field, moving back or using a shorter lens can help as much as changing the aperture.
A simple way to check
Take a test shot, then look at it on the camera screen at full size. Check whether the part that matters is sharp and whether the background is as soft or as busy as you wanted. Adjust the aperture by one step if needed, and try again. Over time, this habit teaches you what each setting does in your own photos.