If I sprained my ankle last week, do I have to keep my foot elevated? What does this do to help it heal?

Maybe. Elevation helps to reduce swelling and somewhat immobilizes the foot and ankle. If you can walk on it and there is not much pain I would use a compression wrap and walk as tolerated.