1. What will be my visa status if i quit my course in june/july after my petition is picked in H1B lottery? Does this have any legal issues if i discontinue the course?
You will be out of status, you may have to go back to H4
2. Is it legal to apply for H1B and also studying the MS course in university at the same time?
Yes, it is