A retaining wall holds back soil on a slope, preventing erosion and creating level, usable space in a yard. It can also define garden beds, patios, or terraced areas.