It depends. When you enroll in an MITx Online course, you are really enrolling in one of that course's available course sessions. Each course session has a specific Start and End Date. You can only attempt each session of an MITx Online course once, so unenrolling from a course session and re-enrolling in the same course session will not provide any additional attempts at passing the course!
However, you can generally participate in as many sessions of an MITx Online course are you wish. If you enroll in a new session of the course, you will be able to attempt it again!
Re-Enrolling in the Same Course Session
If you re-enroll in a course session after unenrolling, you will regain access to the same course session, including any Coursework you may have submitted previously. You cannot reattempt Coursework that you have already used all of the allowed submission attempts for.
Enrolling in a New Course Session
To attempt an MITx Online course again you must enroll in a different session of the course. Most MITx Online courses only run one session at a time, so you will probably need to wait until after the currently-running session ends, and a new session begins.
It's important to note that the schedule of course availability varies greatly between between MITx Online courses. Some courses will start a new session almost as soon as the previous session ends. Other courses may not start a new session for weeks or months after the previous session ends.
For more information about unenrolling from a course session, see this FAQ article