If you want a 3 stars rating, these might be the requirements:
1. Try not to hit walls
2. Don't touch enemies and other things that can hurt you
3. Keep on track, don't get off-road
4. NEVER EVER FALL if you're going for the 3 stars rating
5. Do a lot of special moves drift boosts, wheelies, etc.
6. Be in first place for a good period of time (originally Yoshi1's tip)
7. Be quick, I think you'll get better rating if you finish faster
8. Get a perfect 60 points in the end, 57 is still acceptable I think...
Credit goes to 1j12 of GameFAQs who made a guide about how to get a star rating in MKWii, here's the link:
http://www.gamefaqs.com/boards/genmessage.php?board=942008&topic=43533083