Sperm ejaculated inside the body can live anywhere from a few days to 5 days or more in a woman's reproductive tract. This is why many women get confused about being pregnant. They may have unprotected intercourse while on their period thinking they won't get pregnant, and then not realize that the sperm in their bodies is alive and kicking. Knowing that sperm can survive for even a week inside your body after ejaculation can help to make more responsible decisions regarding unprotected intercourse while not on birth control.
Sperm ejaculated outside the body, however, only lives for a few minutes or a few hours. Once it dries, the sperm is basically useless, and it's exceedingly rare for sperm to have the ability to penetrate clothing, enter the vagina, and still swim all the way into the reproductive tract. However, ejaculation near the vagina, or sperm getting on the outside of the vagina after pulling out (which is a risky form of birth control to begin with) MAY be able to give sperm the ability to enter the vagina and swim its way into the reproductive tract, where it can live much longer. If getting pregnant is a concern and you are not on birth control, use precaution when having intercourse, as there are risks (however small) of sperm finding its way inside your body even if it's not ejaculated in your vagina.